Repository navigation
7.4.6: keep admin editor uploads on the persistent volume - #12
Merged
Merged
Conversation
Image fields and OG images uploaded through the admin page form were written to static/uploads inside the image, which every deploy replaces, so they vanished at the next deploy unless the deploying machine had a copy. They are now written to content/uploads (the Fly volume) through handlers.saveUpload, and /uploads/ serves from handlers.UploadsDir; URLs are unchanged. At startup MigrateLegacyUploads copies files an image still carries in static/uploads into content/uploads without overwriting. Tests: saveUpload, MigrateLegacyUploads (copies only missing regular files, skips dotfiles and folders), and a CreateContent multipart test that the OG image lands under UploadsDir. TestMain points UploadsDir at a temp directory. Also records the pinned Docker base images (#11) in the changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An image field or OG image uploaded through the admin page form was written to
static/uploadsinside the running image. Every deploy replaces the image, so the picture disappeared at the next deploy and the page showed a broken image. It survived only if the machine that ran./deploy.shhappened to have a copy in its ownstatic/uploads, which then got baked into the new image. One such file (1769086431567199000_avatar.png) has been kept alive that way since January.Uploads through the asset library, the API and MCP already go to
content/generated, on the volume, and are unaffected.Change
internal/handlers/uploads.go:saveUploadwrites editor uploads toUploadsDir(content/uploads, on the Fly volume at/app/content). The four editor paths (image fields and OG image, on create and on update) use it. File names and/uploads/...URLs are unchanged, and a failed save is now logged instead of ignored./uploads/serves fromhandlers.UploadsDir.MigrateLegacyUploadscopies any file the image still carries instatic/uploadsintocontent/uploads, never overwriting. So the avatar moves onto the volume on the first start of 7.4.6, and later deploys no longer depend on a local copy.build.json,manifest.jsonand the CHANGELOG. The CHANGELOG also records Pin Docker base images by digest #11, the digest-pinned Docker images.content/.Tests
saveUpload, both the write path and the error when the folder can't be created.MigrateLegacyUploads: it copies only missing regular files, leaves the volume's copy alone, skips dotfiles and folders, and a second run copies nothing.TestCreateContent_OGImageUploadGoesToUploadsDir: a multipart create storesog_imageas an/uploads/URL whose file is underUploadsDir. It needs the test database, so it runs in CI.TestMainpointsUploadsDirat a temp directory.go test ./...passes with database tests skipped, along withgo vetandgofmt.After merging
Deploy with
./deploy.shas usual. The first start logsCopied 1 legacy upload(s) into content/uploads. Thenhttps://metavert.io/uploads/1769086431567199000_avatar.pngshould still return the image. Tagv7.4.6on the merge commit.🤖 Generated with Claude Code