diff --git a/CHANGES.md b/CHANGES.md index 5a7c35cc7..ed75d2d14 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,33 @@ ### :boom: Breaking changes & Deprecations +Although this is not a breaking change, we believe it’s important to highlight it in this +section: + +This release includes a fix for an internal bug in Penpot that caused incorrect handling +of media assets (e.g., fill images). The issue has been resolved since version 2.4.3, so +no new incorrect references will be generated. However, existing files may still contain +incorrect references. + +To address this, we’ve provided a script to correct these references in existing files. + +While having incorrect references generally doesn’t result in visible issues, there are +rare cases where it can cause problems. For example, if a component library (containing +images) is deleted, and that library is being used in other files, running the FileGC task +(responsible for freeing up space and performing logical deletions) could leave those +files with broken references to the images. + +To execute script: + +```bash +docker exec -ti ./run.sh app.migrations.media-refs '{:max-jobs 1}' +``` + +If you have a big database and many cores available, you can reduce the time of processing +all files by increasing paralelizacion changing the `max-jobs` value from 1 to N (where N +is a number of cores) + + ### :heart: Community contributions (Thank you!) ### :sparkles: New features diff --git a/backend/src/app/migrations/media_refs.clj b/backend/src/app/migrations/media_refs.clj new file mode 100644 index 000000000..67cad944e --- /dev/null +++ b/backend/src/app/migrations/media_refs.clj @@ -0,0 +1,49 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + +(ns app.migrations.media-refs + "A media refs migration fixer script" + (:require + [app.common.exceptions :as ex] + [app.common.logging :as l] + [app.common.pprint] + [app.srepl.fixes.media-refs :refer [process-file]] + [app.srepl.main :as srepl] + [clojure.edn :as edn])) + +(def ^:private required-services + [:app.storage.s3/backend + :app.storage.fs/backend + :app.storage/storage + :app.metrics/metrics + :app.db/pool + :app.worker/executor]) + +(defn -main + [& [options]] + (try + (let [config-var (requiring-resolve 'app.main/system-config) + start-var (requiring-resolve 'app.main/start-custom) + stop-var (requiring-resolve 'app.main/stop) + config (select-keys @config-var required-services)] + + (start-var config) + + (let [options (if (string? options) + (ex/ignoring (edn/read-string options)) + {})] + + (l/inf :hint "executing media-refs migration" :options options) + (srepl/process-files! process-file options)) + + (stop-var) + (System/exit 0)) + (catch Throwable cause + (ex/print-throwable cause) + (flush) + (System/exit -1)))) + +