fix(import): name merged parts after their folder and clean up empty ones
This commit is contained in:
@@ -504,3 +504,37 @@ def test_merge_at_download_root_keeps_the_download_dir(client):
|
||||
assert res["ok"], res
|
||||
assert client.downloads.is_dir()
|
||||
assert not (client.downloads / "Teil 1").exists()
|
||||
|
||||
|
||||
def test_merged_parts_clean_up_nested_source_folders(client):
|
||||
""""100 - Toteninsel/A - Sphinx/CD/*.mp3" - every emptied level below the
|
||||
merged item goes away, the cover folder keeps its parent alive."""
|
||||
lib_id = client.post("/api/libraries", json={
|
||||
"name": "L", "media_type": "audiobook", "root_path": str(client.tmp_path / "l"),
|
||||
"folder_template": "{Title}", "file_template": "{Title}",
|
||||
}).json()["id"]
|
||||
req_id = client.post("/api/requests",
|
||||
json={"library_id": lib_id, "title": "Toteninsel"}).json()["id"]
|
||||
|
||||
base = client.downloads / "100 - Toteninsel"
|
||||
files = []
|
||||
for part in ("A - Sphinx", "B - Volk", "C - Graeber"):
|
||||
cd = base / part / "CD"
|
||||
cd.mkdir(parents=True)
|
||||
for i in (1, 2):
|
||||
f = cd / f"{i:02d}.mp3"
|
||||
f.write_bytes(b"")
|
||||
files.append(str(f))
|
||||
(base / "Cover").mkdir()
|
||||
(base / "Cover" / "front.jpg").write_bytes(b"")
|
||||
|
||||
res = client.post("/api/import", json={"items": [{
|
||||
"path": str(base), "is_dir": True, "files": files, "request_id": req_id,
|
||||
}]}).json()["results"][0]
|
||||
assert res["ok"], res
|
||||
assert sorted(p.name for p in Path(res["dest"]).iterdir()) == [
|
||||
f"Toteninsel - Part 0{i}.mp3" for i in range(1, 7)
|
||||
]
|
||||
assert not (base / "A - Sphinx").exists()
|
||||
assert not (base / "B - Volk").exists()
|
||||
assert (base / "Cover" / "front.jpg").exists()
|
||||
|
||||
Reference in New Issue
Block a user