0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 23:31:21 -05:00

Add file snapshoting on migration

This commit is contained in:
Andrey Antukh 2023-11-08 10:45:08 +01:00
parent 47e877d6c3
commit b0418ff5f2
3 changed files with 6 additions and 3 deletions

View file

@ -33,6 +33,7 @@
[app.db :as db] [app.db :as db]
[app.media :as media] [app.media :as media]
[app.rpc.commands.files :as files] [app.rpc.commands.files :as files]
[app.rpc.commands.files-snapshot :as fsnap]
[app.rpc.commands.media :as cmd.media] [app.rpc.commands.media :as cmd.media]
[app.storage :as sto] [app.storage :as sto]
[app.storage.tmp :as tmp] [app.storage.tmp :as tmp]
@ -645,6 +646,9 @@
(let [system (update system ::sto/storage media/configure-assets-storage)] (let [system (update system ::sto/storage media/configure-assets-storage)]
(db/tx-run! system (db/tx-run! system
(fn [{:keys [::db/conn] :as system}] (fn [{:keys [::db/conn] :as system}]
(fsnap/take-file-snapshot! system {:file-id file-id
:label "migration/components-v2"})
(binding [*system* system] (binding [*system* system]
(-> (db/get conn :file {:id file-id}) (-> (db/get conn :file {:id file-id})
(update :features db/decode-pgarray #{}) (update :features db/decode-pgarray #{})

View file

@ -210,6 +210,7 @@
preset :shutdown-on-failure preset :shutdown-on-failure
max-jobs Integer/MAX_VALUE max-jobs Integer/MAX_VALUE
max-items Long/MAX_VALUE}}] max-items Long/MAX_VALUE}}]
(letfn [(get-chunk [cursor] (letfn [(get-chunk [cursor]
(let [sql (str/concat (let [sql (str/concat
"SELECT id, created_at, features FROM team " "SELECT id, created_at, features FROM team "

View file

@ -193,9 +193,7 @@
collectable file-changes entry." collectable file-changes entry."
[system & {:keys [file-id label]}] [system & {:keys [file-id label]}]
(let [file-id (h/parse-uuid file-id)] (let [file-id (h/parse-uuid file-id)]
(db/tx-run! system (db/tx-run! system fsnap/take-file-snapshot! {:file-id file-id :label label})))
(fn [cfg]
(fsnap/take-file-snapshot! cfg {:file-id file-id :label label})))))
(defn restore-file-snapshot! (defn restore-file-snapshot!
[system & {:keys [file-id id]}] [system & {:keys [file-id id]}]