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:
Sunil Mohan Adapa 2019-08-28 15:26:31 -07:00 committed by James Valleroy
parent 143c9e494d
commit 0eb2db3f9a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -39,7 +39,7 @@ from plinth.errors import PlinthError
from plinth.modules import backups, storage
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 .errors import BorgRepositoryDoesNotExistError
from .repository import (BorgRepository, SshBorgRepository, create_repository,
@ -404,9 +404,9 @@ class VerifySshHostkeyView(SuccessMessageMixin, FormView):
messages.error(self.request, message)
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.
store.delete(uuid)
create_repository(uuid).remove()
return redirect(reverse_lazy('backups:add-remote-repository'))
@ -495,7 +495,7 @@ def umount_repository(request, uuid):
def mount_repository(request, uuid):
"""View to mount a remote SSH repository."""
# 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)
repository = SshBorgRepository(uuid=uuid)