refactor(backups): global snapshots

restic-rewrite-api
Houkime 2023-05-31 13:16:08 +00:00
parent 603ed2ddf9
commit 4b07d4de41
3 changed files with 5 additions and 5 deletions

View File

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

View File

@ -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"],

View File

@ -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):