fix: ignore duplicate matches whose file is gone
The hash lives in the database and the file does not, so a file deleted behind the app's back went on refusing its own replacement. Matches are now checked against disk, and re-adding a book's own missing file writes it back into the row that already describes it.
This commit is contained in:
+11
-2
@@ -128,9 +128,18 @@ The policy differs by how deliberate the import is:
|
||||
| `create_many_from_existing_files` (consume watcher) | Skips, and **moves the file to `CHITAI_DUPLICATE_PATH/<library slug>/`** — nothing is deleted, and it cannot stay put because `watchfiles` only reports additions. That path must stay outside `consume_path` or the watcher re-imports it and tries to read the directory name as a library slug. |
|
||||
|
||||
`allow_duplicates=true` overrides all of it, on every endpoint. Keep that working — the
|
||||
hash is not proof of identity, so a false positive has to be recoverable.
|
||||
hash is not proof of identity, so a wrong verdict has to be recoverable, and a scripted
|
||||
import needs a way through. The **web UI deliberately does not offer it**: storing the
|
||||
same bytes twice splits reading progress and shelf membership across two records that
|
||||
can never converge, which is nothing anyone wants on purpose.
|
||||
|
||||
Two things to preserve when touching this code:
|
||||
Three things to preserve when touching this code:
|
||||
|
||||
- **A match only counts while the file is on disk.** `find_duplicate_files` stats each
|
||||
candidate, and `add_files` writes a missing file back into the row that already
|
||||
describes it (`_restore_file`) instead of adding a second row beside it. The hash
|
||||
lives in the database and the file does not, so without this a file deleted behind
|
||||
the app's back would go on refusing its own replacement.
|
||||
|
||||
- **Screening runs before anything is written.** `fingerprint_upload` reads the spooled
|
||||
upload and rewinds it; the resulting fingerprints are handed to `_save_book_files`,
|
||||
|
||||
Reference in New Issue
Block a user