mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
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:
parent
e8b324eece
commit
461741c33f
@ -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.'))
|
||||
|
||||
|
||||
@ -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."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user