fix: preserve upload recovery and harden speech indexing
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user