fix: tolerate OpenList move consistency lag

This commit is contained in:
2026-08-13 16:10:53 +08:00
parent 9b8880a3da
commit 38deb8d593
2 changed files with 51 additions and 4 deletions
+23
View File
@@ -198,6 +198,29 @@ def test_native_trash_and_restore_verify_provider_state(ambiguous_timeout: bool)
assert client.files == {"cloud/library/opaque.bin": 123}
def test_native_trash_waits_for_eventually_consistent_provider(monkeypatch):
class EventuallyConsistentClient(_MovingClient):
stale_reads = 4
def object_info(self, path: str):
trash_path = "cloud/library/.imagefind-native-trash/trash-id/opaque.bin"
if self.stale_reads and path in {"cloud/library/opaque.bin", trash_path}:
self.stale_reads -= 1
if path == "cloud/library/opaque.bin":
return {"name": "opaque.bin", "size": 123, "is_dir": False}
return None
return super().object_info(path)
monkeypatch.setattr("imagefind.openlist_native.time.sleep", lambda _seconds: None)
client = EventuallyConsistentClient({"cloud/library/opaque.bin": 123})
service = _native_service(client)
trash_path = service.trash_object("source", "trash-id", "cloud/library/opaque.bin", 123)
assert trash_path == "cloud/library/.imagefind-native-trash/trash-id/opaque.bin"
assert client.files == {trash_path: 123}
def test_native_trash_restore_conflicts_are_non_destructive_and_purge_is_idempotent():
trash_path = "cloud/library/.imagefind-native-trash/trash-id/opaque.bin"
client = _MovingClient({"cloud/library/opaque.bin": 123, trash_path: 123})