mirror of
https://github.com/penpot/penpot.git
synced 2025-06-09 12:51:40 +02:00
🎉 Add migration-like script for execute media-refs fix
This commit is contained in:
parent
16934b734b
commit
bfe9a2b545
2 changed files with 76 additions and 0 deletions
27
CHANGES.md
27
CHANGES.md
|
@ -6,6 +6,33 @@
|
||||||
|
|
||||||
### :boom: Breaking changes & Deprecations
|
### :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 <container-name-or-id> ./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!)
|
### :heart: Community contributions (Thank you!)
|
||||||
|
|
||||||
### :sparkles: New features
|
### :sparkles: New features
|
||||||
|
|
49
backend/src/app/migrations/media_refs.clj
Normal file
49
backend/src/app/migrations/media_refs.clj
Normal file
|
@ -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))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue