From a6c9ced5b39bd21a763de2701952c04807bb01a5 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 22 Mar 2024 12:59:16 +0100 Subject: [PATCH] :bug: Fix minor issue on internal srepl helpers --- backend/src/app/srepl/helpers.clj | 19 +++++++++++-------- backend/src/app/srepl/main.clj | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/backend/src/app/srepl/helpers.clj b/backend/src/app/srepl/helpers.clj index 010a0aa7a..38ea61dd8 100644 --- a/backend/src/app/srepl/helpers.clj +++ b/backend/src/app/srepl/helpers.clj @@ -35,15 +35,18 @@ (defn get-file "Get the migrated data of one file." - ([id] (get-file (or *system* main/system) id)) - ([system id] + ([id] (get-file (or *system* main/system) id nil)) + ([system id & {:keys [raw?] :as opts}] (db/run! system (fn [system] - (binding [pmap/*load-fn* (partial feat.fdata/load-pointer system id)] - (-> (files/get-file system id :migrate? false) - (update :data feat.fdata/process-pointers deref) - (update :data feat.fdata/process-objects (partial into {})) - (fmg/migrate-file))))))) + (let [file (files/get-file system id :migrate? false)] + (if raw? + file + (binding [pmap/*load-fn* (partial feat.fdata/load-pointer system id)] + (-> file + (update :data feat.fdata/process-pointers deref) + (update :data feat.fdata/process-objects (partial into {})) + (fmg/migrate-file))))))))) (defn update-file! [system {:keys [id] :as file}] @@ -166,7 +169,7 @@ (fsnap/take-file-snapshot! system {:file-id file-id :label label})) (let [conn (db/get-connection system) - file (get-file system file-id) + file (get-file system file-id opts) libs (when with-libraries? (->> (files/get-file-libraries conn file-id) (into [file] (map (fn [{:keys [id]}] diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index 17df79a9a..2f538d6f6 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -429,7 +429,9 @@ (try (l/trc :hint "process:file:start" :file-id (str file-id) :index idx) (let [system (assoc main/system ::db/rollback rollback?)] - (db/tx-run! system h/process-file! file-id update-fn opts)) + (db/tx-run! system (fn [system] + (binding [h/*system* system] + (h/process-file! system file-id update-fn opts))))) (catch Throwable cause (l/wrn :hint "unexpected error on processing file (skiping)"