Match local files to e621: MD5 lookups, manual links, batch scans

- MediaItem gains e621_match_status (unknown/matched/not_found/deleted)
  and e621_checked_at, backfilled for existing matched items.
- Server-side e621 client (apps/library/e621.py) using the user's stored
  credentials, throttled to 2 req/s, with typed errors.
- Matching service: MD5 lookup, manual post linking (flags MD5
  mismatches), unlink, metadata refresh, deleted-post detection.
- Detail actions POST /api/files/J-x/match/ and /unlink/ (uploader or
  staff only).
- Background library scans: MatchTask + /api/matches/ with missing/all
  scopes, progress polling, cancel and stale-task reaping; the scan
  counts toward the footer's Active Workers. Same pass available as
  manage.py match_e621 for cron.
- Library gains not_found/deleted status filters; the detail page adds
  an e621 match card (check / link by post ID / unlink) and the metadata
  card warns when a post was deleted on e621.
This commit is contained in:
2026-09-17 13:41:08 -05:00
parent db74f7ab18
commit 09405d1a0f
16 changed files with 1084 additions and 27 deletions
+10 -5
View File
@@ -31,10 +31,14 @@ they land.
- [x] The status footer's "Active Workers" now counts running download tasks
- [x] **Download to client** — streams the e621 original straight to the
browser (works for guests; host-restricted proxy, no library write)
- [ ] **Match local files to e621**
- [ ] Match by MD5 from the library detail (manual post ID entry)
- [ ] Batch cache status for the whole library (`matched` / `not_found` / `deleted`)
- [ ] Show match status + e621 metadata in the library (model already supports it)
- [x] **Match local files to e621**
- [x] Match by MD5 from the library detail, plus manual post ID linking
(with an MD5-mismatch warning) and unlink
- [x] Batch cache status for the whole library (`matched` / `not_found` /
`deleted`) via background scan tasks (`/api/matches/`) and
`manage.py match_e621`
- [x] Show match status + e621 metadata in the library: status badge and
match card on the detail, and `not_found` / `deleted` status filters
- [ ] **IQDB reverse search**
- [ ] Search from a local file (`POST /iqdb_queries.json`)
- [ ] Show candidate posts to link
@@ -104,4 +108,5 @@ Files now stage first and are resolved before entering the library.
- Download progress, optimization jobs and the stats "Active Workers" count all
want the same background-task/progress primitive — design it once.
- IQDB and e621 matching depend on e621 credentials being configured; the SPA
already talks to e621 directly where possible.
talks to e621 directly for browsing, while the backend e621 client
(`apps/library/e621.py`) handles metadata matching and batch scans.