List files copied into the uploads folder by hand in the media library

The library only knew files uploaded through the admin. Listing it
now registers any image in the uploads folder that has no media row,
under its own name and unprocessed, at most every 30 seconds.
Non-images, dotfiles and temporary names are skipped. The delete
check also counts records that name a file by its bare filename, and
a hand-copied name is escaped in its URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 23:53:09 -05:00
parent dad3803ccc
commit 8ec34ea185
3 changed files with 144 additions and 11 deletions

View file

@ -23,6 +23,17 @@ in the `media` table (`server/src/migrations/028_media.sql`).
Limits and sizes are constants at the top of `server/src/media.js`.
## Files copied in by hand
A file put straight into the uploads directory (with `scp`, say) shows
up in the library the next time the Media page or an image picker opens:
the server registers any image it finds there without a record, under
the file's own name, kept as it is (not resized). Anything that isn't a
JPEG, PNG, GIF, WebP or SVG is ignored. A record can name such a file by
its bare filename (eg. `fall-retreat-logo.svg`), which resolves to
`/uploads/<file>`, and the delete check counts those uses too. Keep the
files readable by the `ngu-api` user.
## Local development
The API reads `UPLOADS_DIR` (default `./uploads`, so `server/uploads/`,