mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-25 18:26:34 +00:00
fix(backups): robustness against stale locks: everything else
This commit is contained in:
parent
0eb70e1551
commit
2c9011cc87
|
@ -345,6 +345,7 @@ class ResticBackupper(AbstractBackupper):
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
raise ValueError("cannot restore a snapshot: " + output) from error
|
raise ValueError("cannot restore a snapshot: " + output) from error
|
||||||
|
|
||||||
|
@unlocked_repo
|
||||||
def restore_from_backup(
|
def restore_from_backup(
|
||||||
self,
|
self,
|
||||||
snapshot_id,
|
snapshot_id,
|
||||||
|
@ -406,6 +407,7 @@ class ResticBackupper(AbstractBackupper):
|
||||||
output,
|
output,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unlocked_repo
|
||||||
def forget_snapshot(self, snapshot_id) -> None:
|
def forget_snapshot(self, snapshot_id) -> None:
|
||||||
"""
|
"""
|
||||||
Either removes snapshot or marks it for deletion later,
|
Either removes snapshot or marks it for deletion later,
|
||||||
|
@ -441,10 +443,7 @@ class ResticBackupper(AbstractBackupper):
|
||||||
) # none should be impossible after communicate
|
) # none should be impossible after communicate
|
||||||
if handle.returncode != 0:
|
if handle.returncode != 0:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"forget exited with errorcode",
|
"forget exited with errorcode", handle.returncode, ":", output, err
|
||||||
handle.returncode,
|
|
||||||
":",
|
|
||||||
output,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _load_snapshots(self) -> object:
|
def _load_snapshots(self) -> object:
|
||||||
|
@ -470,8 +469,9 @@ class ResticBackupper(AbstractBackupper):
|
||||||
try:
|
try:
|
||||||
return ResticBackupper.parse_json_output(output)
|
return ResticBackupper.parse_json_output(output)
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
raise ValueError("Cannot load snapshots: ") from error
|
raise ValueError("Cannot load snapshots: ", output) from error
|
||||||
|
|
||||||
|
@unlocked_repo
|
||||||
def get_snapshots(self) -> List[Snapshot]:
|
def get_snapshots(self) -> List[Snapshot]:
|
||||||
"""Get all snapshots from the repo"""
|
"""Get all snapshots from the repo"""
|
||||||
snapshots = []
|
snapshots = []
|
||||||
|
|
|
@ -794,6 +794,15 @@ def test_operations_while_locked(backups, dummy_service):
|
||||||
Backups.provider().backupper.lock()
|
Backups.provider().backupper.lock()
|
||||||
assert Backups.snapshot_restored_size(snap.id) > 0
|
assert Backups.snapshot_restored_size(snap.id) > 0
|
||||||
|
|
||||||
|
Backups.provider().backupper.lock()
|
||||||
|
Backups.restore_snapshot(snap)
|
||||||
|
|
||||||
|
Backups.provider().backupper.lock()
|
||||||
|
Backups.forget_snapshot(snap)
|
||||||
|
|
||||||
|
Backups.provider().backupper.lock()
|
||||||
|
assert Backups.provider().backupper.get_snapshots() == []
|
||||||
|
|
||||||
# check that no locks were left
|
# check that no locks were left
|
||||||
Backups.provider().backupper.lock()
|
Backups.provider().backupper.lock()
|
||||||
Backups.provider().backupper.unlock()
|
Backups.provider().backupper.unlock()
|
||||||
|
|
Loading…
Reference in a new issue