0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-03 04:49:03 -05:00

Simplify srepl helper for shape deletion

This commit is contained in:
Andrey Antukh 2024-01-31 18:59:45 +01:00
parent e8c35c2de6
commit 3a401f69fd

View file

@ -8,7 +8,6 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.logging :as l] [app.common.logging :as l]
[app.common.types.shape :as cts]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.db :as db] [app.db :as db]
[app.features.components-v2 :as feat] [app.features.components-v2 :as feat]
@ -18,7 +17,6 @@
[app.util.events :as events] [app.util.events :as events]
[app.util.time :as dt] [app.util.time :as dt]
[app.worker :as-alias wrk] [app.worker :as-alias wrk]
[clojure.set :as set]
[cuerdas.core :as str] [cuerdas.core :as str]
[promesa.exec :as px] [promesa.exec :as px]
[promesa.exec.semaphore :as ps] [promesa.exec.semaphore :as ps]
@ -407,30 +405,10 @@
(defn delete-broken-files (defn delete-broken-files
[{:keys [id data] :as file}] [{:keys [id data] :as file}]
(let [xform (comp (if (-> data :options :components-v2 true?)
(map val) (do
(map :objects) (l/wrn :hint "found old components-v2 format"
(mapcat vals) :file-id (str id)
(map :type)) :file-name (:name file))
stypes (-> (into #{} xform (:pages-index data)) (assoc file :deleted-at (dt/now)))
(set/difference cts/shape-types))] file))
(cond
(seq stypes)
(do
(l/wrn :hint "found shapes with unknown types"
:file-id (str id)
:file-name (:name file)
: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)
:file-name (:name file))
(assoc file :deleted-at (dt/now)))
:else
file)))