From 761b6be4e5f197bb9450df012d250c4b87363d20 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 31 May 2023 13:16:08 +0000 Subject: [PATCH] refactor(backups): global snapshots --- selfprivacy_api/backup/__init__.py | 2 +- selfprivacy_api/backup/restic_backuper.py | 6 +++--- tests/test_graphql/test_backup.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/selfprivacy_api/backup/__init__.py b/selfprivacy_api/backup/__init__.py index b10ee39..4e13ea9 100644 --- a/selfprivacy_api/backup/__init__.py +++ b/selfprivacy_api/backup/__init__.py @@ -253,7 +253,7 @@ class Backups: # TODO: the oldest snapshots will get expired faster than the new ones. # How to detect that the end is missing? - upstream_snapshots = Backups.provider().backuper.get_snapshots(service_id) + upstream_snapshots = Backups.provider().backuper.get_snapshots() Backups.sync_service_snapshots(service_id, upstream_snapshots) return upstream_snapshots diff --git a/selfprivacy_api/backup/restic_backuper.py b/selfprivacy_api/backup/restic_backuper.py index c16f444..2c98b46 100644 --- a/selfprivacy_api/backup/restic_backuper.py +++ b/selfprivacy_api/backup/restic_backuper.py @@ -212,7 +212,7 @@ class ResticBackuper(AbstractBackuper): if "restoring" not in output: raise ValueError("cannot restore a snapshot: " + output) - def _load_snapshots(self, repo_name) -> object: + def _load_snapshots(self) -> object: """ Load list of snapshots from repository raises Value Error if repo does not exist @@ -237,10 +237,10 @@ class ResticBackuper(AbstractBackuper): except ValueError as e: raise ValueError("Cannot load snapshots: ") from e - def get_snapshots(self, repo_name) -> List[Snapshot]: + def get_snapshots(self) -> List[Snapshot]: """Get all snapshots from the repo""" snapshots = [] - for restic_snapshot in self._load_snapshots(repo_name): + for restic_snapshot in self._load_snapshots(): snapshot = Snapshot( id=restic_snapshot["short_id"], created_at=restic_snapshot["time"], diff --git a/tests/test_graphql/test_backup.py b/tests/test_graphql/test_backup.py index 3e1536e..a50fed4 100644 --- a/tests/test_graphql/test_backup.py +++ b/tests/test_graphql/test_backup.py @@ -151,7 +151,7 @@ def test_backup_service(dummy_service, backups): def test_no_repo(memory_backup): with pytest.raises(ValueError): - assert memory_backup.backuper.get_snapshots("") == [] + assert memory_backup.backuper.get_snapshots() == [] def test_one_snapshot(backups, dummy_service):