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 authored and James Valleroy committed 2018-12-13 18:28:38 -05:00
1 parent 067fea7d17
commit b2f5d68ca6
2 files changed
+4 -3

No files matched your search

+2 -2
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)
+2 -1
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)