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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-08-28 15:15:34 -07:00 committed by James Valleroy
parent e8b324eece
commit 461741c33f
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 8 additions and 3 deletions

View File

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

View File

@ -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."""