mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
✨ Add helper for mark for deletion invalid files
This commit is contained in:
parent
13ca5d1f1a
commit
f97931647c
1 changed files with 30 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.logging :as l]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
[app.features.components-v2 :as feat]
|
||||
|
@ -17,6 +18,7 @@
|
|||
[app.util.events :as events]
|
||||
[app.util.time :as dt]
|
||||
[app.worker :as-alias wrk]
|
||||
[clojure.set :as set]
|
||||
[cuerdas.core :as str]
|
||||
[promesa.exec :as px]
|
||||
[promesa.exec.semaphore :as ps]
|
||||
|
@ -398,3 +400,31 @@
|
|||
(l/dbg :hint "migrate:end"
|
||||
:rollback rollback?
|
||||
:elapsed elapsed)))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; FILE PROCESS HELPERS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn delete-broken-files
|
||||
[{:keys [id data] :as file}]
|
||||
(let [xform (comp
|
||||
(map val)
|
||||
(map :objects)
|
||||
(mapcat vals)
|
||||
(map :type))
|
||||
stypes (-> (into #{} xform (:pages-index data))
|
||||
(set/difference cts/shape-types))]
|
||||
|
||||
(cond
|
||||
(seq stypes)
|
||||
(do
|
||||
(l/wrn :hint "found shapes with unknown types" :file-id (str id) :types stypes)
|
||||
(assoc file :deleted-at (dt/now)))
|
||||
|
||||
(-> data :options :components-v2 true?)
|
||||
(do
|
||||
(l/wrn :hint "found old components-v2 format" :file-id (str id))
|
||||
(assoc file :deleted-at (dt/now)))
|
||||
|
||||
:else
|
||||
file)))
|
||||
|
|
Loading…
Add table
Reference in a new issue