Skip to content

PhoenixKit 2.41.0: Storage profiles, variant sets and automatic file repair

PhoenixKit 2.41.0 lets each media library say where its files are kept and which image sizes its uploads get. A background job then moves, copies and resizes files until they match. A site that never changes anything keeps working as before, on a seeded Default profile and variant set.

Storage profiles

Settings → Media → Storage profiles lists buckets and gives each a role: Primary (written and served), Replica (served when no primary has the file) or Backup (written but never served). A bucket in a profile can store everything, only originals, or only sizes and tiles, can be Read-only or Draining, and has a write priority and serve order. The profile also sets how many copies a file gets and how many an upload needs to succeed. A system library picks its profile on the Libraries tab.

Variant sets

The image dimensions page is now Variant sets, with a tab per set. Each set has its own sizes and says whether sizes and zoomable tiles are made. The standard sizes (thumbnail, small, medium, large and video thumbnail) cannot be deleted or renamed. An admin can mark a set selectable, so users can pick it for their own libraries.

The reconciler

A background job now brings files in line with their library’s profile and set. It copies first and removes a copy only after checking that the remaining copies exist, never the last one. It also makes missing sizes, remakes sizes whose settings changed and removes sizes a set no longer has. It runs after changes and daily. The Health page shows what is still waiting. Until a size exists, the nearest smaller size or a placeholder is shown instead of the full original.

Media fixes

  • Dragging an attached file onto a folder no longer shows it in both folders.
  • Restore is on the file, row and folder menus and the bulk bar, and dragging a trashed file into a folder restores it there.
  • A failed upload no longer deletes stored bytes that another file uses.
  • Bucket usage now counts files under 1 MB, so a bucket’s size limit can be reached.

Upgrading

Run mix phoenix_kit.update for migration V205. It adds tables and columns and seeds the Default profile and set, and copies or resizes nothing itself. Every bucket joins the Default profile in its current read order; a disabled bucket stays disabled. Files that already had too few copies are queued, and the reconciler fixes them gradually on the file_processing queue. The Sync All button on the Health page is gone.

Full release notes: PhoenixKit 2.41.0

2.41.0 · 26 September 2026

Storage profiles, variant sets and the reconciler (V205, phase 4 of dev_docs/plans/2026-09-22-storage-libraries.md). Each library now says where its files are kept and which sizes its uploads get. Nothing changes for an install that never touches them: every library starts on the seeded Default profile and variant set, built from the existing buckets and settings.

Upgrading

  • Run mix phoenix_kit.update (migration V205). It adds the new tables and columns and seeds the Defaults; it copies, moves and resizes nothing. Files that were already under-replicated are marked for the reconciler, which then makes their missing copies by itself, throttled, on the file_processing queue. Settings → Media → Health shows what is left.
  • Every bucket joins the Default profile, in today’s read order (local first, then by priority). A disabled bucket stays disabled: enabled is still the emergency stop.
  • The Sync All button on the Health page is gone; the reconciler does that work. A sync already queued before the upgrade just queues the reconciler.

Added

  • Storage profiles: where a library’s files are kept. A profile lists buckets and gives each a role (primary is written and served, replica is served when no primary has the copy, backup is written but never served), what it stores (everything, originals only, or sizes and tiles only), a fixed write priority or the random pool, a serve order, and a status (read-only serves but gets no new files; draining has its files moved off). It also says how many copies an original and a derived file get, and how many copies an upload needs to succeed. Settings → Media → Storage profiles; a system library picks its profile on the Libraries tab.
  • Variant sets: which sizes a library’s uploads get. A set has its own sizes (names are unique per set, not site-wide) and says whether sizes and zoomable tiles are made. Every set has the standard sizes (thumbnail, small, medium, large, video_thumbnail), which cannot be deleted or renamed; small, medium and large keep the aspect ratio. The dimensions page is now Variant sets, a tab per set. A user may pick, for a library they own, a set an admin marked selectable.
  • The reconciler (Storage.Workers.ReconcileJob) moves files to where their library’s profile wants them, copying first and removing a copy only once the copies that stay are checked to be really there (never the last one); it deletes an object from a bucket only when nothing else there still needs it. It also makes missing sizes, remakes sizes whose spec changed, and removes sizes a set no longer has; a thumbnail with an annotation burned into it is never made over. It runs by itself, throttled, after any change and daily; a file it cannot finish is tried again ten minutes later. The Health page lists the files still waiting and can queue a pass.
  • A missing size is no longer served as the full original. Until a size that is being made exists, the nearest smaller size the file has stands in, else a placeholder; neither is cached. A size that will not be made (the set makes none, the size is disabled) still serves the original, as before.
  • Storage.variant_for(file, min_width: 300, aspect: :preserve) picks a size by purpose against the file’s own set.
  • mix phoenix_kit.doctor warns about a variant set missing a standard size.

Changed

  • Variants and tiles are placed by the library’s profile as derived files, rather than onto exactly the original’s buckets.
  • storage_redundancy_copies, storage_auto_generate_variants and storage_tile_generation_enabled are now the Default profile’s and the Default variant set’s (Storage.redundancy_copies/0, get_auto_generate_variants/0, tile_generation_enabled?/0 and their setters); the rows are kept in step for code that still reads them. The Configuration tab labels its three controls accordingly.
  • A cross-user copy reuses another file’s stored bytes only when both libraries use the same profile and variant set.
  • Deleting an empty bucket takes it out of every storage profile; a new bucket joins the Default profile, as it joined the pool before.
  • An upload whose write fails on one bucket tries the next eligible one before giving up a copy.

Fixed

  • Dragging a file onto a folder no longer shows it in both. A file attached somewhere (a featured image, a gallery) is linked as well as homed. Moving it used to re-point the link and leave the home, so the file appeared in the folder it was dropped on and the one it came from. A folder now holds a file once, as its home or through a link.
  • Trash can be left. Restore is on the file menu, the row menu, the folder menu and the bulk bar. Dragging a trashed file into a folder restores it there. Restoring a file whose folder is also trashed puts it in the nearest folder that is still there, or at the root, instead of an active file inside a trashed folder where nothing lists it.
  • A failed upload no longer deletes bytes another file uses. Keys are content-addressed, so a second upload of the same bytes writes the same key; undoing a failed one now happens under the key’s lock and only when nothing else references the key or is still writing it.
  • Bucket usage counts small files. Each file was rounded down to whole megabytes before summing, so files under 1 MB counted as nothing and a bucket’s max_size_mb never tripped; a key shared by cross-user copies is now counted once.

Removed

  • The Health page’s manual sync (progress bar, pause, stop): the reconciler does it. SyncFilesJob only queues the reconciler, for jobs already queued, and goes in the next release. Storage.get_health_report/1 and sync_under_replicated/1,3 are gone.

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