From b0418ff5f2524f1179cae1968138e3e9451b98be Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 8 Nov 2023 10:45:08 +0100 Subject: [PATCH] :sparkles: Add file snapshoting on migration --- backend/src/app/features/components_v2.clj | 4 ++++ backend/src/app/srepl/components_v2.clj | 1 + backend/src/app/srepl/main.clj | 4 +--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index f26cd50c9..c6389cd8d 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -33,6 +33,7 @@ [app.db :as db] [app.media :as media] [app.rpc.commands.files :as files] + [app.rpc.commands.files-snapshot :as fsnap] [app.rpc.commands.media :as cmd.media] [app.storage :as sto] [app.storage.tmp :as tmp] @@ -645,6 +646,9 @@ (let [system (update system ::sto/storage media/configure-assets-storage)] (db/tx-run! system (fn [{:keys [::db/conn] :as system}] + (fsnap/take-file-snapshot! system {:file-id file-id + :label "migration/components-v2"}) + (binding [*system* system] (-> (db/get conn :file {:id file-id}) (update :features db/decode-pgarray #{}) diff --git a/backend/src/app/srepl/components_v2.clj b/backend/src/app/srepl/components_v2.clj index 2b709b627..b6cb138b4 100644 --- a/backend/src/app/srepl/components_v2.clj +++ b/backend/src/app/srepl/components_v2.clj @@ -210,6 +210,7 @@ preset :shutdown-on-failure max-jobs Integer/MAX_VALUE max-items Long/MAX_VALUE}}] + (letfn [(get-chunk [cursor] (let [sql (str/concat "SELECT id, created_at, features FROM team " diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index da7f21120..e468d3fc4 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -193,9 +193,7 @@ collectable file-changes entry." [system & {:keys [file-id label]}] (let [file-id (h/parse-uuid file-id)] - (db/tx-run! system - (fn [cfg] - (fsnap/take-file-snapshot! cfg {:file-id file-id :label label}))))) + (db/tx-run! system fsnap/take-file-snapshot! {:file-id file-id :label label}))) (defn restore-file-snapshot! [system & {:keys [file-id id]}]