Skip to content

PhoenixKit 2.40.0: Storage reads follow where each file really is

PhoenixKit 2.40.0 makes Media read each file from the buckets that actually hold it, tightens what contributors may do in a user library, and lets a library owner bring back a trashed library.

Files are read from where they are

Reading and serving a file now goes first to the buckets its location records name, local first, then by priority. Only when none has it are the other enabled buckets tried, and a bucket that turns out to hold it is recorded. Tiles and comment attachments now record where they were stored too, and an image size is written to the same buckets as its original.

Files stored before this release are located in the background: each enabled bucket is checked once per file, and the result, a miss included, is remembered. Settings → Media → Health shows how many are left, and the files are served meanwhile. The upload API now uses the same SHA-256 checksum as every other upload path, so the same file uploaded two ways is no longer stored twice; old MD5 checksums are recomputed in the background.

A bucket that still holds files can no longer be deleted; the settings page says to disable it instead. Bucket changes now apply at once instead of after up to five minutes.

User libraries

In a user library, a contributor can now change only the files they uploaded. Folder names and looks stay shared. An owner can restore a trashed library from a Trash section on the profile’s Media tab until it is purged. An Owner or Admin opening a file of someone’s library at /admin/media/:uuid is written to the audit log, as opening the library already was.

Media viewer layout

The media viewer now picks its layout by the window’s shape, not only its width. A tall window, such as a portrait monitor, gets the stacked layout and a much larger picture.

Upgrading

Run mix phoenix_kit.update for migration V204. It removes duplicate file location rows, adds indexes and a table for location checks, and stops a bucket’s deletion from silently removing its location rows. PhoenixKit now needs phoenix_kit_templates 0.2. In a host’s own email template override, the html part now escapes {{variable}}; a variable that holds markup, such as {{line_items_html}}, must be written {{{variable}}}. Core’s own emails do not change. Module authors get PhoenixKit.Migrations.Adoption for safely taking over core tables.

Full release notes: PhoenixKit 2.40.0

2.40.0 · 25 September 2026

Added

  • PhoenixKit.Migrations.Adoption (#868, refs #862). A public, stability-committed API for module migration chains that adopt a core-baseline table. verify_shape/3 checks the table’s real shape (column type/nullability/default, indexes, constraints, sequences, functions) before the module writes its ownership marker, and reports every drifted or missing object in one pass; format_drift/1 renders that report. marker_conflict/5 refuses to overwrite another module’s marker or an operator’s own table comment, while treating core’s pre-squash descriptive comments as safe to overwrite. It never writes anything. Recommended use (raise on drift by default, or log and adopt under an explicit per-host :warn opt-in) is in the moduledoc and the module table extraction guide.

Changed

  • A user library’s contributor changes only the files they uploaded. The media browser refuses their change to anyone else’s file, a folder trash, delete or move whose subtree holds one, a bulk action on a selection holding either, and emptying the trash; folder names and looks stay shared. Before, the browser had no per-file check.
  • A trashed user library can be restored by its owner until it is purged, from a Trash section on the profile’s Media tab (Libraries.restore_library/2). It gets a URL slug again, counts toward the per-user limit, and is refused while a live library has its name.
  • An Owner or Admin opening a user-library file’s detail page at /admin/media/:uuid is written to the audit log (storage.library_opened), like opening the library itself.
  • phoenix_kit_templates 0.2.0 (pin ~> 0.1.0 → ~> 0.2.0). A host override’s html part now HTML-escapes a bound {{variable}}; a variable that already holds markup must use {{{variable}}}. Core’s own defaults are text-only, so core’s messages don’t change. Database templates keep their own {{var}} substitution. Check any hand-written or exported html.html override that uses {{line_items_html}} (or another markup variable).
  • Dependency updates: phoenix_live_reload 1.7.0 (dev; pin ~> 1.6.1 → ~> 1.7), mdex 0.14.0, hackney 4.8.1, lazy_html 0.1.13 (test).
  • Storage reads follow where a file actually is (V204, location-truth). Reading, serving and checking a stored object go first to the buckets its location rows name, local first, then by priority. Only when none has it are the other enabled buckets tried, and a bucket found to hold it that way is recorded. Every writer now records where it stored: Tessera tiles and comment attachments did not. A variant is written to exactly the buckets its original is in; before, that list was capped at the redundancy setting and reordered.
  • Files stored before location-truth are located in the background. Storage.Workers.LocationBackfillJob checks each enabled bucket once for every stored object not checked yet, records every bucket that has it, and remembers the check, a miss included (a new phoenix_kit_file_location_checks table), so a missing object is not asked about on every request. It queues itself shortly after boot and from the daily trash prune while any are left, runs one batch every few seconds, and Settings → Media → Health shows how many are left. Those files are served meanwhile.
  • One checksum for every upload path. The upload API hashed files with MD5 while everything else used SHA-256, so the same file uploaded both ways was stored twice. It uses SHA-256 now, and Storage.Workers.ChecksumBackfillJob (queued like the location backfill) recomputes the MD5 checksums already stored from each file’s bytes. A file whose uploader already has the same bytes is left as it is.
  • A bucket that still holds files cannot be deleted. Deleting one used to drop its location rows silently and leave its objects behind. The settings page says to disable the bucket instead.
  • Bucket changes apply at once. Adding, editing or removing a bucket used to take up to five minutes to reach file serving (a cache).

Fixed

  • The media viewer lays itself out by the window’s shape, not its width (#874). A tall window that happened to be wide (a portrait monitor, a half-screen split) kept the side-by-side split and squeezed a landscape picture into a narrow column: at 1100×1500 the picture got 688×318 before, 1031×477 now. A portrait window gets the stacked layout, with the picture pane sized to the picture and the popup hugging the two.

Migration notes

  • V204 removes duplicate phoenix_kit_file_locations rows (keeping the oldest of each instance and bucket), adds a unique index on that pair and an index on path, and moves the location’s bucket FK from ON DELETE CASCADE to RESTRICT. It adds phoenix_kit_file_location_checks and marks every instance that already has a location row as checked, so only the rest are probed.

PhoenixKit 2.40.0. Install or update: {:phoenix_kit, "~> 2.40"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.