711a0ae4

Author: Michael Lynch <git@mtlynch.io>

Committer: Michael Lynch <mtlynch@noreply.codeberg.org>

Move media publishing out of the upload handlers (#401)

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.

Reviewed-on: https://codeberg.org/mtlynch/little-moments/pulls/401

Suite timing

Time to Start Worker time Duration Time to finish Idle
Config 2s 12s 12s 14s 2s
Eval 11s 45s 45s 56s 0s
Build 28s 6m45s 1m30s 1m59s 0s
Deploy 2m20s 3m23s 3m23s 5m43s 21s
Suite 2s 11m05s 5m40s 5m43s 23s

Timeline

0s1m3m4m5m