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
+9
View File
@@ -5,6 +5,15 @@ CHITAI_TOKEN_SECRET=secret
CHITAI_DEFAULT_LIBRARY_NAME=Books
CHITAI_DEFAULT_LIBRARY_PATH="libraries/books"
# Duplicate detection when importing files (optional).
# Scope: "library" compares against the library being uploaded to, "global" against
# every library, "off" disables the check.
CHITAI_DUPLICATE_SCOPE=library
# Where the consume watcher parks files it refused as duplicates. Keep it outside
# CHITAI_CONSUME_PATH, or the watcher picks them straight back up.
CHITAI_DUPLICATE_PATH="duplicates"
# You probably should not change these
CHITAI_API_URL="http://backend:8000"
CHITAI_API_DEBUG=false