diff --git a/CLAUDE.md b/CLAUDE.md index 64b0926..45f9323 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1220,6 +1220,12 @@ serialization path.** It enforces: cue lines, in Traktor's shape (`HOTCUE="-1"`, `n.n.`), add + delete round-trips byte for byte, new cues (hot ones too) are INSERTED by START, and a pad + memory cue at one START project once, as the pad. + And **`>` / quotes in attribute values** (Q): Traktor leaves `>` raw, and + an empty element holding one (4.5's default "Recently added" query + `$IMPORTDATE >= MONTHS_AGO(1)`, a comment, a file name) once came back + self-closed (`/>`, which Traktor never writes); a value containing + `name='x'` once came back with a bare `"` (malformed). Both were in the + fork's `format_traktor_layout`, fixed there (2026-10-16). The guard that catches serialization regressions like the lxml reformatting bug. - `test_phase3.py` — full create/add/reorder/rename/delete/save cycle stays Traktor-valid, backup-first, COLLECTION byte-identical, original untouched; diff --git a/backend/requirements-server.txt b/backend/requirements-server.txt index 20dda75..2f0ee87 100644 --- a/backend/requirements-server.txt +++ b/backend/requirements-server.txt @@ -14,5 +14,5 @@ Pillow>=11 # a Rekordbox add writes the cover's artwork files dulwich>=0.22 # version history, beside the library platformdirs>=4.0 # From GitHub, NOT PyPI — see requirements.txt for why. -traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@39a9c15f29d6b0ea2ce61cd7d548501eea38319d +traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@d7f472aaf5be53e53921de351e948233e9c1d1e8 pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git@43137cb91f8297c768d2a8bdce5b27b2225f0a2d diff --git a/backend/requirements.txt b/backend/requirements.txt index c18c19f..887d50b 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -24,7 +24,7 @@ scikit-learn>=1.5 # what it had: pyrekordbox renamed `devicelib_plus` to `onelibrary` upstream, # every local test passed, and the released app could not export or read a # OneLibrary stick. Move a pin deliberately, with ./run_tests.sh. -traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@39a9c15f29d6b0ea2ce61cd7d548501eea38319d +traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@d7f472aaf5be53e53921de351e948233e9c1d1e8 # Rekordbox (master.db is SQLCipher-encrypted SQLite + per-track ANLZ analysis # files). Both ship prebuilt Python 3.14 wheels — no Rust/OpenSSL source build. # diff --git a/backend/test_save_fidelity.py b/backend/test_save_fidelity.py index 522de90..9988254 100644 --- a/backend/test_save_fidelity.py +++ b/backend/test_save_fidelity.py @@ -1305,5 +1305,41 @@ with tempfile.TemporaryDirectory() as d: check("both cues stay in the file", sum(1 for c in entry.cue_v2 if c.grid is None and c.hotcue == -1) == 2) +print("== Q. '>' and quotes in attribute values round-trip (Traktor leaves '>' raw) ==") +# The real collection's queries hold no '>', so Traktor-written values with one +# are injected into a copy: Traktor 4.5's default "Recently added" smartlist, +# a '<' query (Traktor escapes it), and '>' / name='x' in a comment and a file +# name. All four once came back self-closed (""), which Traktor never +# writes, and a quoting step rewrote name='x' into a bare '"' (malformed XML). +import re as _re # noqa: E402 + +with tempfile.TemporaryDirectory() as d: + work = Path(d) / "collection.nml" + data = REAL.read_bytes() + queries = list(_re.finditer(rb'QUERY="[^"]*"', data)) + swaps = [ + (queries[0].group(0), b'QUERY="$IMPORTDATE >= MONTHS_AGO(1)"'), + (queries[1].group(0), b'QUERY="$RATING < 3"'), + (_re.search(rb' COMMENT="[^"]*"', data).group(0), b" COMMENT=\"Classic > Move key='8A'\""), + (_re.search(rb' FILE="[^"]*"', data).group(0), b' FILE="Break Down > Build Up.wav"'), + ] + for old, new in swaps: + data = data.replace(old, new, 1) + work.write_bytes(data) + store = TraktorStore(work) + out = store._render() + check("no-op render is byte-identical", out == data, f"{diff_count(data, out)} lines differ") + check("nothing is self-closed ('/>' — Traktor never writes it)", b"/>" not in out) + + entry = store._nml.collection.entry[0] + tid = f"{entry.location.volume}{entry.location.dir}{entry.location.file}" + store.set_track_metadata(tid, {"comment": "x > y key='8A' \"z\""}) + store.save() + saved = work.read_bytes() + check("an edited comment with '>' keeps ", + b"COMMENT=\"x > y key='8A' "z"\"" in saved and b"/>" not in saved) + reread = TraktorStore(work)._nml.collection.entry[0].info.comment + check("…and reads back unchanged", reread == "x > y key='8A' \"z\"", repr(reread)) + print("\nRESULT:", "FAILED" if failed else "ALL PASSED") sys.exit(1 if failed else 0)