mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 00:19:15 +00:00
fix(backup):force backup function to return same length ids as when getting snapshots
This commit is contained in:
parent
b01247bc55
commit
26488aa12f
|
@ -19,6 +19,8 @@ from selfprivacy_api.jobs import Jobs, JobStatus
|
|||
|
||||
from selfprivacy_api.backup.local_secret import LocalBackupSecret
|
||||
|
||||
SHORT_ID_LEN = 8
|
||||
|
||||
|
||||
class ResticBackupper(AbstractBackupper):
|
||||
def __init__(self, login_flag: str, key_flag: str, storage_type: str) -> None:
|
||||
|
@ -177,7 +179,9 @@ class ResticBackupper(AbstractBackupper):
|
|||
@staticmethod
|
||||
def _snapshot_from_fresh_summary(message: dict, repo_name) -> Snapshot:
|
||||
return Snapshot(
|
||||
id=message["snapshot_id"],
|
||||
# There is a discrepancy between versions of restic/rclone
|
||||
# Some report short_id in this field and some full
|
||||
id=message["snapshot_id"][0:SHORT_ID_LEN],
|
||||
created_at=datetime.datetime.now(datetime.timezone.utc),
|
||||
service_name=repo_name,
|
||||
)
|
||||
|
|
|
@ -205,6 +205,8 @@ def test_backup_returns_snapshot(backups, dummy_service):
|
|||
snapshot = provider.backupper.start_backup(service_folders, name)
|
||||
|
||||
assert snapshot.id is not None
|
||||
assert len(snapshot.id) == len(Backups.get_all_snapshots()[0].id)
|
||||
assert Backups.get_snapshot_by_id(snapshot.id) is not None
|
||||
assert snapshot.service_name == name
|
||||
assert snapshot.created_at is not None
|
||||
|
||||
|
|
Loading…
Reference in a new issue