fix(reading): accept browser-zipped EPUB folder uploads

This commit is contained in:
lorenzozanee
2026-10-13 02:40:11 +08:00
parent 3cbecb2479
commit 981bd0e17f
2 changed files with 10 additions and 0 deletions

View File

@@ -1058,6 +1058,8 @@ async def upload_material(
filename = (file.filename or "").strip()
if not filename:
raise HTTPException(status_code=400, detail="The upload has no filename.")
if filename.lower().endswith(".epub.zip"):
filename = filename[: -len(".zip")]
tmp_dir = Path(tempfile.mkdtemp(prefix="dt-reading-"))
tmp_path = tmp_dir / Path(filename).name

View File

@@ -436,6 +436,14 @@ def test_epub_render_response_is_normalized_and_raw_preserves_upload(client: Tes
assert all("__MACOSX" not in info.filename for info in infos)
def test_upload_unwraps_a_safari_folder_drag_epub_zip(client: TestClient) -> None:
material = _upload(client, name="book.epub.zip", data=_epub_bytes(finder_package=True))
assert material["render_mode"] == "epub"
assert material["unit_count"] >= 1
assert material["filename"] == "book.epub"
def test_epub_pairing_requires_confirmation_and_preserves_source_materials(
client: TestClient,
) -> None: