feature(backups): enable snapshot cache usage

This commit is contained in:
Houkime 2023-04-07 17:24:53 +00:00 committed by Inex Code
parent 2c510ae884
commit f9eaaab929

View file

@ -321,9 +321,16 @@ class Backups:
@staticmethod @staticmethod
def get_snapshots(service: Service) -> List[Snapshot]: def get_snapshots(service: Service) -> List[Snapshot]:
repo_name = service.get_id() service_id = service.get_id()
cached_snapshots = Backups.get_cached_snapshots_service(service_id)
if cached_snapshots != []:
return cached_snapshots
# TODO: the oldest snapshots will get expired faster than the new ones.
# How to detect that the end is missing?
return Backups.provider().backuper.get_snapshots(repo_name) upstream_snapshots = Backups.provider().backuper.get_snapshots(service_id)
Backups.sync_service_snapshots(service_id, upstream_snapshots)
return upstream_snapshots
@staticmethod @staticmethod
def restore_service_from_snapshot(service: Service, snapshot_id: str): def restore_service_from_snapshot(service: Service, snapshot_id: str):