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 <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
Sunil Mohan Adapa 2019-06-24 16:42:28 -07:00 committed by Joseph Nuthalapati
parent 9c8674baa3
commit 984b7dca88
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
2 changed files with 7 additions and 10 deletions

View File

@ -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)

View File

@ -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)