From 37890488542584b28a8bea1b198823ce6ccc1d00 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 6 Jan 2021 20:07:10 -0800 Subject: [PATCH] backups: Allow storing root repository details - This allows schedule to be stored along with the repository information. Tests performed: - Storing/retrieving a schedule along with root repository works. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/backups/repository.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plinth/modules/backups/repository.py b/plinth/modules/backups/repository.py index 5245c4274..13e4aad46 100644 --- a/plinth/modules/backups/repository.py +++ b/plinth/modules/backups/repository.py @@ -484,17 +484,24 @@ def _ssh_connection(hostname, username, password): def get_repositories(): """Get all repositories of a given storage type.""" - repositories = [get_instance(RootBorgRepository.UUID)] - for uuid in store.get_storages(): + repositories = [] + storages = store.get_storages() + for uuid in storages: repositories.append(get_instance(uuid)) + if RootBorgRepository.UUID not in storages: + repositories.append(get_instance(RootBorgRepository.UUID)) + return sorted(repositories, key=lambda x: x.sort_order) def get_instance(uuid): """Create a local or SSH repository object instance.""" if uuid == RootBorgRepository.UUID: - return RootBorgRepository() + try: + return RootBorgRepository.load(uuid) + except KeyError: + return RootBorgRepository() storage = store.get(uuid) if storage['storage_type'] == 'ssh':