fix: preserve upload recovery and harden speech indexing

This commit is contained in:
2026-08-12 19:49:25 +08:00
parent 10f2c078ec
commit a0a185b96c
16 changed files with 13234 additions and 62 deletions
+34
View File
@@ -1,4 +1,5 @@
from contextlib import nullcontext
from pathlib import Path
from types import SimpleNamespace
import httpx
@@ -114,6 +115,39 @@ def test_native_catalog_uses_physical_object_but_keeps_logical_media_identity():
assert item.fingerprint
def test_native_prepare_and_cancel_preserve_original_and_local_recovery(tmp_path: Path):
original = tmp_path / "upload.part"
original.write_bytes(b"data")
staging = tmp_path / "native"
class Sources:
rclone = SimpleNamespace()
def get(self, _source_id):
return {}
service = object.__new__(OpenListNativeService)
service.sources = Sources()
service.configuration = lambda _source: SimpleNamespace(
local_staging_path=staging,
encrypted=False,
source_path="local-stage",
target_path="cloud",
)
paths = service.prepare("source", "upload-id", "folder/movie.mp4", original)
assert original.read_bytes() == b"data"
assert Path(paths["local_path"]).read_bytes() == b"data"
cancelled: list[str] = []
service.client = lambda _source_id: SimpleNamespace(
cancel_copy_task=lambda task_id: cancelled.append(task_id)
)
service.cancel("source", "upload-id", "task-id", paths["staged_path"])
assert cancelled == ["task-id"]
assert original.is_file()
assert Path(paths["local_path"]).is_file()
class _MovingClient:
def __init__(self, files: dict[str, int], *, fail_after_move: bool = False):
self.files = dict(files)