3.1 KiB
3.1 KiB
This release adds a duplicate purge to the media library: owners and admins can merge identical images in one action, or let RenewCMS do it on a schedule.
New
Media duplicate purge
- Purge duplicates from the Duplicates tab of the media library with the new toolbar button, or from the new Media cleanup card in Settings. A summary shows how many copies would be merged and how many articles would be updated before you confirm.
- For each group of identical images used in at least one article, the most used copy is kept, with ties going to the oldest. Every other copy is merged into it and the articles that used them are rewritten. Groups where no copy is used are left alone.
- If the library changes between the summary and the confirmation, nothing is purged and you are asked to check the new summary.
- Turn on automatic purge in Settings and choose an interval from 1 to 365 days, 30 by default. The first run happens one interval after you turn it on, then once per interval after each run.
- The Media cleanup card shows the last run, with the number of copies merged and articles updated, and the date of the next one.
- The purge is reserved for owners and admins. Editors get a clear message instead of the controls.
- The new screens are available in English and French.
API
GET /v1/media/purge-settingsreturns the automatic purge settings:auto_purge_enabled,auto_purge_interval_days,last_purge_at,last_purge_merged,last_purge_articles_updatedandnext_purge_at, which isnullwhile automatic purge is off.PATCH /v1/media/purge-settingsupdatesauto_purge_enabledandauto_purge_interval_days. An interval outside 1 to 365 answers400.GET /v1/media/purge-previewreturns what a purge would do, with afingerprintof the plan. It changes nothing.POST /v1/media/purgeruns the purge. Send the preview'sfingerprintto refuse a run if the library changed: a stale fingerprint answers409, and so does a purge that is already running.- All four routes answer
403with "Only owners and admins can do this." for any other role, and accept a session only, like the rest of the media routes.
Under the hood
- Add the purge domain, a SQLite repository for the single-row purge settings, and the use cases that build the plan, preview it, run it and decide when a scheduled run is due.
- Add an hourly scheduler, started with the server after a one-minute delay and stopped on shutdown. It reads the settings on every tick, so changes apply without a restart, and a failed run is retried at the next tick.
- Add the
RequireOwnerOrAdminmiddleware. - Add the media purge, scheduler and Settings card specifications and QA procedures to
features/, the new screens todocs/design/, and Go and Vitest suites for each part.
Upgrading
- Replace the binary, or pull the new image. The purge settings table is created automatically at startup. No new environment variable is required.
- Automatic purge is off after the upgrade. Nothing is merged until an owner or admin runs a purge or turns it on.
- A purge cannot be undone: merged copies are removed. Check the summary before confirming.