Backups: allow creating archive in unmounted repository

- mount repository if necessary before creating an archive

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Michael Pimmer 2018-12-10 13:51:10 +01:00 committed by James Valleroy
parent 067fea7d17
commit b2f5d68ca6
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 4 additions and 3 deletions

View File

@ -359,9 +359,9 @@ def get_ssh_repositories():
return repositories
def get_repository(uuid):
def get_repository(uuid, automount=False):
"""Get a repository (BorgRepository or SshBorgRepository)"""
if uuid == ROOT_REPOSITORY_UUID:
return BorgRepository(path=ROOT_REPOSITORY)
else:
return SshBorgRepository(uuid=uuid, automount=False)
return SshBorgRepository(uuid=uuid, automount=automount)

View File

@ -92,7 +92,8 @@ class CreateArchiveView(SuccessMessageMixin, FormView):
def form_valid(self, form):
"""Create the archive on valid form submission."""
repository = get_repository(form.cleaned_data['repository'])
repository = get_repository(form.cleaned_data['repository'],
automount=True)
name = datetime.now().strftime('%Y-%m-%d:%H:%M')
repository.create_archive(name, form.cleaned_data['selected_apps'])
return super().form_valid(form)