5142292e

By: Michael Lynch <git@mtlynch.io>

Move media publishing out of the upload handlers

The image and video upload handlers each built a MediaItem inline, ran
the processor, and inserted the database row. That sequence was
duplicated across both paths and tied HTTP request handling directly to
media processing and storage, making the publish workflow awkward to
test without driving the full server.

Introduce a media.Service that owns the publish workflow end to end: it
constructs the MediaItem, processes the upload into its file variants,
then records the media row. Handlers now depend on a narrow
MediaPublisher interface and hand off the parsed request via
PublishImage/PublishVideo.

This keeps the write-files-before-insert ordering (which leaves orphaned
files rather than a gallery entry pointing at missing files on a failed
insert) in one place and lets the publishing logic be tested directly,
without the HTTP layer.

Suite timing

Time to Start Worker time Duration Time to finish Idle
Config 2s 18s 18s 21s 2s
Eval 18s 53s 53s 1m11s 0s
Build 54s 9m10s - - 0s
Suite 2s 10m22s - - 21h49m56s

Timeline

0s20s40s1m1m20s1m40s2m2m20s