feat: check for duplicate files when importing books

Incoming files are matched against what is already stored, keyed on the
KOReader hash and the file size. Bulk uploads skip and report them, deliberate
creates are refused with a 409, the consume directory parks them aside, and
allow_duplicates overrides all three.

Also: books whose metadata generates a path another book already owns are moved
aside, so a forced copy cannot overwrite the original's files.
This commit is contained in:
2026-08-13 17:23:48 -04:00
parent 968166c1fd
commit d78b21c27f
14 changed files with 1422 additions and 67 deletions
+7 -1
View File
@@ -40,7 +40,13 @@ pytest_plugins = [
@pytest.fixture(autouse=True)
def _patch_settings(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(settings, "book_cover_path", f"{tmp_path}/covers")
# PIL will not create the directory it is asked to save into, so anything that
# imports a file carrying a cover needs it to exist first.
covers = tmp_path / "covers"
covers.mkdir()
monkeypatch.setattr(settings, "book_cover_path", str(covers))
monkeypatch.setattr(settings, "duplicate_path", str(tmp_path / "duplicates"))
@pytest.fixture(name="engine")