mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 07:21:27 +00:00
refactor(backups): global snapshots
This commit is contained in:
parent
a76b4ac134
commit
761b6be4e5
|
@ -253,7 +253,7 @@ class Backups:
|
||||||
# TODO: the oldest snapshots will get expired faster than the new ones.
|
# TODO: the oldest snapshots will get expired faster than the new ones.
|
||||||
# How to detect that the end is missing?
|
# 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)
|
Backups.sync_service_snapshots(service_id, upstream_snapshots)
|
||||||
return upstream_snapshots
|
return upstream_snapshots
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ class ResticBackuper(AbstractBackuper):
|
||||||
if "restoring" not in output:
|
if "restoring" not in output:
|
||||||
raise ValueError("cannot restore a snapshot: " + 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
|
Load list of snapshots from repository
|
||||||
raises Value Error if repo does not exist
|
raises Value Error if repo does not exist
|
||||||
|
@ -237,10 +237,10 @@ class ResticBackuper(AbstractBackuper):
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise ValueError("Cannot load snapshots: ") from 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"""
|
"""Get all snapshots from the repo"""
|
||||||
snapshots = []
|
snapshots = []
|
||||||
for restic_snapshot in self._load_snapshots(repo_name):
|
for restic_snapshot in self._load_snapshots():
|
||||||
snapshot = Snapshot(
|
snapshot = Snapshot(
|
||||||
id=restic_snapshot["short_id"],
|
id=restic_snapshot["short_id"],
|
||||||
created_at=restic_snapshot["time"],
|
created_at=restic_snapshot["time"],
|
||||||
|
|
|
@ -151,7 +151,7 @@ def test_backup_service(dummy_service, backups):
|
||||||
|
|
||||||
def test_no_repo(memory_backup):
|
def test_no_repo(memory_backup):
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
assert memory_backup.backuper.get_snapshots("") == []
|
assert memory_backup.backuper.get_snapshots() == []
|
||||||
|
|
||||||
|
|
||||||
def test_one_snapshot(backups, dummy_service):
|
def test_one_snapshot(backups, dummy_service):
|
||||||
|
|
Loading…
Reference in a new issue