From 461741c33f277f60ad6bbaf0e688747675fe7870 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 28 Aug 2019 15:15:34 -0700 Subject: [PATCH] backups: Expose repository path as property Make consumers depend on the repository classes instead of lower level store API. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/backups/forms.py | 6 +++--- plinth/modules/backups/repository.py | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plinth/modules/backups/forms.py b/plinth/modules/backups/forms.py index 0a6ced275..e8ec09088 100644 --- a/plinth/modules/backups/forms.py +++ b/plinth/modules/backups/forms.py @@ -32,7 +32,7 @@ from django.utils.translation import ugettext_lazy as _ from plinth.modules.storage import get_disks from plinth.utils import format_lazy -from . import api, split_path, store +from . import api, split_path from .repository import get_repositories logger = logging.getLogger(__name__) @@ -202,8 +202,8 @@ class AddRemoteRepositoryForm(EncryptedBackupsMixin, forms.Form): @staticmethod def _check_if_duplicate_remote(path): """Raise validation error if given path is a stored remote.""" - for storage in store.get_storages().values(): - if storage['path'] == path: + for repository in get_repositories(): + if repository.path == path: raise forms.ValidationError( _('Remote backup repository already exists.')) diff --git a/plinth/modules/backups/repository.py b/plinth/modules/backups/repository.py index 819bde4e1..8da25ca24 100644 --- a/plinth/modules/backups/repository.py +++ b/plinth/modules/backups/repository.py @@ -110,6 +110,11 @@ class BaseBorgRepository(abc.ABC): """Return a display name for the repository.""" return self._path + @property + def path(self): + """Return the path of the repository.""" + return self._path + @abc.abstractmethod def storage_type(self): """Return the storage type of repository."""