mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 09:42:01 +00:00
✨ Add a flag that makes file-gc skip its media clean-up (#13220)
The new backend flag `file-change-retention`, off by default, makes file-gc skip its media clean-up (deleted components, unused media objects, and thumbnails). That clean-up roots only in the head and the snapshots, so it would remove media that a kept revision row still names. The file and fragment clean-up still run: revision rows name neither. penpot#13187 keeps revision rows under the same flag. Set the flag only where both are deployed. An instance that rolls back to this release with the flag still set keeps the media its retained history needs. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
212ee6ef48
commit
932544996f
@ -272,9 +272,14 @@
|
||||
(feat.fdata/with-pointers cfg file-id
|
||||
(let [liveness (collect-snapshot-liveness cfg file-id)
|
||||
original (feat.fdata/original-pointers (:data file))
|
||||
file (bfl/clean-file file)
|
||||
;; With retention on, kept revision rows can name media and
|
||||
;; components that neither the head nor the snapshots name,
|
||||
;; and the media cleaners do not read those rows.
|
||||
file (if (contains? cf/flags :file-change-retention)
|
||||
file
|
||||
(clean-media! cfg liveness file))
|
||||
file (->> file
|
||||
(bfl/clean-file)
|
||||
(clean-media! cfg liveness)
|
||||
(feat.fdata/reattach-unchanged original)
|
||||
(clean-fragments! cfg (:pointers liveness)))
|
||||
file (assoc file :has-media-trimmed true)]
|
||||
|
||||
@ -3537,6 +3537,22 @@
|
||||
(t/is (true? (th/run-task! :file-gc {:file-id (:id file)})))
|
||||
(t/is (empty? (:call-args-list @audit-mock)))))))
|
||||
|
||||
(t/deftest file-gc-keeps-unused-media-with-the-retention-flag
|
||||
;; A kept revision row can name a media object that the head no longer
|
||||
;; names, and file-gc does not read revision rows, so the flag turns its
|
||||
;; media clean-up off.
|
||||
(let [[_ file-1] (unused-media-fixture 1)
|
||||
[_ file-2] (unused-media-fixture 2)
|
||||
media-row (fn [file] (th/db-get :file-media-object {:file-id (:id file)}
|
||||
{::db/remove-deleted false}))]
|
||||
(t/is (true? (th/run-task! :file-gc {:file-id (:id file-1)})))
|
||||
(with-redefs [cf/flags (conj cf/flags :file-change-retention)]
|
||||
(t/is (true? (th/run-task! :file-gc {:file-id (:id file-2)}))))
|
||||
|
||||
(t/is (ct/inst? (:deleted-at (media-row file-1))))
|
||||
(t/is (nil? (:deleted-at (media-row file-2))))
|
||||
(t/is (true? (:has-media-trimmed (th/db-get :file {:id (:id file-2)}))))))
|
||||
|
||||
(t/deftest update-file-audit-event-carries-the-file-change-id
|
||||
;; The event says that a file was saved, but not what changed: the
|
||||
;; change row (xlog) is the only place with that, so its id travels
|
||||
|
||||
@ -90,6 +90,11 @@
|
||||
;; on the database (server-error-report) and notified to mattermost
|
||||
;; (only when the webhook url is also configured).
|
||||
:error-reporting
|
||||
;; Disabled by default. When enabled, file-gc skips its media clean-up,
|
||||
;; which does not read revision rows, and the revision writer keeps
|
||||
;; revision rows with no expiry (penpot#13187). Enable it only where
|
||||
;; both are deployed.
|
||||
:file-change-retention
|
||||
;; Activates the schema validation during update file.
|
||||
:file-schema-validation
|
||||
;; Reports the schema validation errors internally.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user