22 lines
790 B
Python
22 lines
790 B
Python
from pathlib import Path
|
|
|
|
from am_deduper.db import connect
|
|
from am_deduper.scanner import scan
|
|
|
|
|
|
def test_replacing_file_invalidates_content_hashes(tmp_path: Path):
|
|
root = tmp_path / "AllMusic"
|
|
(root / "admin").mkdir(parents=True)
|
|
path = root / "admin" / "song.flac"
|
|
db = root / ".dedupe" / "dedupe.db"
|
|
path.write_bytes(b"first" * 1000)
|
|
scan(root, db)
|
|
with connect(db) as c:
|
|
c.execute("UPDATE audio_tracks SET sha256='old-sha', chromaprint='old-fp' WHERE file_path=?", (str(path),))
|
|
path.write_bytes(b"second" * 1000)
|
|
scan(root, db)
|
|
with connect(db) as c:
|
|
row = c.execute("SELECT sha256,chromaprint FROM audio_tracks WHERE file_path=?", (str(path),)).fetchone()
|
|
assert row["sha256"] is None
|
|
assert row["chromaprint"] is None
|