mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🐛 Remove a race condition on file export
Caused when file is deleted in the middle of an exportation. The current export process is not transactional, and on file deletion several queries can start return not-found exception because of concurrent file deletion. With the changes on this PR we allow query deleted files internally on the exportation process and make it resilent to possible concurrent deletion.
This commit is contained in:
@@ -550,7 +550,7 @@
|
|||||||
[cfg data file-id]
|
[cfg data file-id]
|
||||||
(let [library-ids (get-libraries cfg [file-id])]
|
(let [library-ids (get-libraries cfg [file-id])]
|
||||||
(reduce (fn [data library-id]
|
(reduce (fn [data library-id]
|
||||||
(if-let [library (get-file cfg library-id)]
|
(if-let [library (get-file cfg library-id :include-deleted? true)]
|
||||||
(ctf/absorb-assets data (:data library))
|
(ctf/absorb-assets data (:data library))
|
||||||
data))
|
data))
|
||||||
data
|
data
|
||||||
|
|||||||
@@ -228,6 +228,7 @@
|
|||||||
(db/tx-run! cfg (fn [cfg]
|
(db/tx-run! cfg (fn [cfg]
|
||||||
(cond-> (bfc/get-file cfg file-id
|
(cond-> (bfc/get-file cfg file-id
|
||||||
{:realize? true
|
{:realize? true
|
||||||
|
:include-deleted? true
|
||||||
:lock-for-update? true})
|
:lock-for-update? true})
|
||||||
detach?
|
detach?
|
||||||
(-> (ctf/detach-external-references file-id)
|
(-> (ctf/detach-external-references file-id)
|
||||||
@@ -285,13 +286,11 @@
|
|||||||
|
|
||||||
(let [file (cond-> (select-keys file bfc/file-attrs)
|
(let [file (cond-> (select-keys file bfc/file-attrs)
|
||||||
(:options data)
|
(:options data)
|
||||||
(assoc :options (:options data))
|
(assoc :options (:options data)))
|
||||||
|
|
||||||
:always
|
file (-> file
|
||||||
(dissoc :data))
|
(dissoc :data)
|
||||||
|
(dissoc :deleted-at)
|
||||||
file (cond-> file
|
|
||||||
:always
|
|
||||||
(encode-file))
|
(encode-file))
|
||||||
|
|
||||||
path (str "files/" file-id ".json")]
|
path (str "files/" file-id ".json")]
|
||||||
|
|||||||
Reference in New Issue
Block a user