mirror of
https://github.com/penpot/penpot.git
synced 2025-06-28 17:47:02 +02:00
✨ Minor improvement on reference handling on touched-gc task
This commit is contained in:
parent
974084a9ca
commit
aeed535f1b
1 changed files with 6 additions and 3 deletions
|
@ -350,14 +350,15 @@
|
||||||
|
|
||||||
(retrieve-touched-chunk [conn cursor]
|
(retrieve-touched-chunk [conn cursor]
|
||||||
(let [rows (->> (db/exec! conn [sql:retrieve-touched-objects-chunk cursor])
|
(let [rows (->> (db/exec! conn [sql:retrieve-touched-objects-chunk cursor])
|
||||||
(mapv #(d/update-when % :metadata db/decode-transit-pgobject)))]
|
(mapv #(d/update-when % :metadata db/decode-transit-pgobject)))
|
||||||
|
kw (fn [o] (if (keyword? o) o (keyword o)))]
|
||||||
(when (seq rows)
|
(when (seq rows)
|
||||||
[(-> rows peek :created-at)
|
[(-> rows peek :created-at)
|
||||||
;; NOTE: we use the :file-media-object as default value for backward compatibility because when we
|
;; NOTE: we use the :file-media-object as default value for backward compatibility because when we
|
||||||
;; deploy it we can have old backend instances running in the same time as the new one and we can
|
;; deploy it we can have old backend instances running in the same time as the new one and we can
|
||||||
;; still have storage-objects created without reference value. And we know that if it does not
|
;; still have storage-objects created without reference value. And we know that if it does not
|
||||||
;; have value, it means :file-media-object.
|
;; have value, it means :file-media-object.
|
||||||
(d/group-by' #(or (-> % :metadata :reference) :file-media-object) :id rows)])))
|
(d/group-by' #(or (some-> % :metadata :reference kw) :file-media-object) :id rows)])))
|
||||||
|
|
||||||
(retrieve-touched [conn]
|
(retrieve-touched [conn]
|
||||||
(->> (d/iteration (fn [cursor]
|
(->> (d/iteration (fn [cursor]
|
||||||
|
@ -391,7 +392,9 @@
|
||||||
(let [[f d] (case reference
|
(let [[f d] (case reference
|
||||||
:file-media-object (process-objects! conn has-file-media-object-nrefs? ids)
|
:file-media-object (process-objects! conn has-file-media-object-nrefs? ids)
|
||||||
:team-font-variant (process-objects! conn has-team-font-variant-nrefs? ids)
|
:team-font-variant (process-objects! conn has-team-font-variant-nrefs? ids)
|
||||||
(ex/raise :type :internal :code :unexpected-unknown-reference))]
|
(ex/raise :type :internal
|
||||||
|
:code :unexpected-unknown-reference
|
||||||
|
:hint (format "unknown reference %s" (pr-str reference))))]
|
||||||
(recur (+ to-freeze f)
|
(recur (+ to-freeze f)
|
||||||
(+ to-delete d)
|
(+ to-delete d)
|
||||||
(rest groups)))
|
(rest groups)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue