mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
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:
parent
9c8674baa3
commit
984b7dca88
@ -237,8 +237,7 @@ class SshBorgRepository(BorgRepository):
|
|||||||
storage_type = 'ssh'
|
storage_type = 'ssh'
|
||||||
uuid = None
|
uuid = None
|
||||||
|
|
||||||
def __init__(self, uuid=None, path=None, credentials=None, automount=False,
|
def __init__(self, uuid=None, path=None, credentials=None, **kwargs):
|
||||||
**kwargs):
|
|
||||||
"""
|
"""
|
||||||
Instanciate a new repository.
|
Instanciate a new repository.
|
||||||
|
|
||||||
@ -259,10 +258,6 @@ class SshBorgRepository(BorgRepository):
|
|||||||
else:
|
else:
|
||||||
self._load_from_kvstore()
|
self._load_from_kvstore()
|
||||||
|
|
||||||
if automount:
|
|
||||||
if is_ssh_hostkey_verified(path):
|
|
||||||
self.mount()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def repo_path(self):
|
def repo_path(self):
|
||||||
"""
|
"""
|
||||||
@ -391,9 +386,9 @@ def get_ssh_repositories():
|
|||||||
return repositories
|
return repositories
|
||||||
|
|
||||||
|
|
||||||
def get_repository(uuid, automount=False):
|
def get_repository(uuid):
|
||||||
"""Get a local or SSH repository object instance."""
|
"""Get a local or SSH repository object instance."""
|
||||||
if uuid == ROOT_REPOSITORY_UUID:
|
if uuid == ROOT_REPOSITORY_UUID:
|
||||||
return BorgRepository(path=ROOT_REPOSITORY)
|
return BorgRepository(path=ROOT_REPOSITORY)
|
||||||
|
|
||||||
return SshBorgRepository(uuid=uuid, automount=automount)
|
return SshBorgRepository(uuid=uuid)
|
||||||
|
|||||||
@ -100,8 +100,10 @@ class CreateArchiveView(SuccessMessageMixin, FormView):
|
|||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Create the archive on valid form submission."""
|
"""Create the archive on valid form submission."""
|
||||||
repository = get_repository(form.cleaned_data['repository'],
|
repository = get_repository(form.cleaned_data['repository'])
|
||||||
automount=True)
|
if hasattr(repository, 'mount'):
|
||||||
|
repository.mount()
|
||||||
|
|
||||||
name = datetime.now().strftime('%Y-%m-%d:%H:%M')
|
name = datetime.now().strftime('%Y-%m-%d:%H:%M')
|
||||||
repository.create_archive(name, form.cleaned_data['selected_apps'])
|
repository.create_archive(name, form.cleaned_data['selected_apps'])
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user