From 984b7dca88f317e100603c739b67255bec78b07a Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 24 Jun 2019 16:42:28 -0700 Subject: [PATCH] backups: Cleanup auto-mounting SSH repositories Remove auto-mounting of repositories during instantiation entirely. It is better to explicitly mount later. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Joseph Nuthalapati --- plinth/modules/backups/repository.py | 11 +++-------- plinth/modules/backups/views.py | 6 ++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/plinth/modules/backups/repository.py b/plinth/modules/backups/repository.py index 2f974aa68..3f15fb8a4 100644 --- a/plinth/modules/backups/repository.py +++ b/plinth/modules/backups/repository.py @@ -237,8 +237,7 @@ class SshBorgRepository(BorgRepository): storage_type = 'ssh' uuid = None - def __init__(self, uuid=None, path=None, credentials=None, automount=False, - **kwargs): + def __init__(self, uuid=None, path=None, credentials=None, **kwargs): """ Instanciate a new repository. @@ -259,10 +258,6 @@ class SshBorgRepository(BorgRepository): else: self._load_from_kvstore() - if automount: - if is_ssh_hostkey_verified(path): - self.mount() - @property def repo_path(self): """ @@ -391,9 +386,9 @@ def get_ssh_repositories(): return repositories -def get_repository(uuid, automount=False): +def get_repository(uuid): """Get a local or SSH repository object instance.""" if uuid == ROOT_REPOSITORY_UUID: return BorgRepository(path=ROOT_REPOSITORY) - return SshBorgRepository(uuid=uuid, automount=automount) + return SshBorgRepository(uuid=uuid) diff --git a/plinth/modules/backups/views.py b/plinth/modules/backups/views.py index 9b567666c..6e3fa31fd 100644 --- a/plinth/modules/backups/views.py +++ b/plinth/modules/backups/views.py @@ -100,8 +100,10 @@ class CreateArchiveView(SuccessMessageMixin, FormView): def form_valid(self, form): """Create the archive on valid form submission.""" - repository = get_repository(form.cleaned_data['repository'], - automount=True) + repository = get_repository(form.cleaned_data['repository']) + if hasattr(repository, 'mount'): + repository.mount() + name = datetime.now().strftime('%Y-%m-%d:%H:%M') repository.create_archive(name, form.cleaned_data['selected_apps']) return super().form_valid(form)