mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
backups: Use higher level method in views instead of store methods
Make store an internal implementation detail of the repository class and achieve better abstraction. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
143c9e494d
commit
0eb2db3f9a
@ -39,7 +39,7 @@ from plinth.errors import PlinthError
|
|||||||
from plinth.modules import backups, storage
|
from plinth.modules import backups, storage
|
||||||
|
|
||||||
from . import (SESSION_PATH_VARIABLE, api, forms, get_known_hosts_path,
|
from . import (SESSION_PATH_VARIABLE, api, forms, get_known_hosts_path,
|
||||||
is_ssh_hostkey_verified, split_path, store)
|
is_ssh_hostkey_verified, split_path)
|
||||||
from .decorators import delete_tmp_backup_file
|
from .decorators import delete_tmp_backup_file
|
||||||
from .errors import BorgRepositoryDoesNotExistError
|
from .errors import BorgRepositoryDoesNotExistError
|
||||||
from .repository import (BorgRepository, SshBorgRepository, create_repository,
|
from .repository import (BorgRepository, SshBorgRepository, create_repository,
|
||||||
@ -404,9 +404,9 @@ class VerifySshHostkeyView(SuccessMessageMixin, FormView):
|
|||||||
|
|
||||||
messages.error(self.request, message)
|
messages.error(self.request, message)
|
||||||
messages.error(self.request, _('Repository removed.'))
|
messages.error(self.request, _('Repository removed.'))
|
||||||
# Delete the repository so that the user can have another go at
|
# Remove the repository so that the user can have another go at
|
||||||
# creating it.
|
# creating it.
|
||||||
store.delete(uuid)
|
create_repository(uuid).remove()
|
||||||
return redirect(reverse_lazy('backups:add-remote-repository'))
|
return redirect(reverse_lazy('backups:add-remote-repository'))
|
||||||
|
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ def umount_repository(request, uuid):
|
|||||||
def mount_repository(request, uuid):
|
def mount_repository(request, uuid):
|
||||||
"""View to mount a remote SSH repository."""
|
"""View to mount a remote SSH repository."""
|
||||||
# Do not mount unverified ssh repositories. Prompt for verification.
|
# Do not mount unverified ssh repositories. Prompt for verification.
|
||||||
if not store.get(uuid).get('verified'):
|
if not create_repository(uuid).is_usable():
|
||||||
return redirect('backups:verify-ssh-hostkey', uuid=uuid)
|
return redirect('backups:verify-ssh-hostkey', uuid=uuid)
|
||||||
|
|
||||||
repository = SshBorgRepository(uuid=uuid)
|
repository = SshBorgRepository(uuid=uuid)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user