mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 09:16:51 +00:00
refactor(backups): introduce get_all_snapshots()
This commit is contained in:
parent
cc073155db
commit
550f7fa620
|
@ -247,16 +247,20 @@ class Backups:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_snapshots(service: Service) -> List[Snapshot]:
|
def get_snapshots(service: Service) -> List[Snapshot]:
|
||||||
service_id = service.get_id()
|
snapshots = Backups.get_all_snapshots()
|
||||||
cached_snapshots = Backups.get_cached_snapshots_service(service_id)
|
return [snap for snap in snapshots if snap.service_name == service.get_id()]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_all_snapshots() -> List[Snapshot]:
|
||||||
|
cached_snapshots = Storage.get_cached_snapshots()
|
||||||
if cached_snapshots != []:
|
if cached_snapshots != []:
|
||||||
return cached_snapshots
|
return cached_snapshots
|
||||||
# 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()
|
upstream_snapshots = Backups.provider().backuper.get_snapshots()
|
||||||
Backups.sync_service_snapshots(service_id, upstream_snapshots)
|
Backups.sync_all_snapshots()
|
||||||
return [snap for snap in upstream_snapshots if snap.service_name == service_id]
|
return upstream_snapshots
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_snapshot_by_id(id: str) -> Optional[Snapshot]:
|
def get_snapshot_by_id(id: str) -> Optional[Snapshot]:
|
||||||
|
|
Loading…
Reference in a new issue