From b49a4734ff2861500ab66a40ce7fb587695b3218 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 15 Apr 2025 10:30:27 +0200 Subject: [PATCH] :bug: Fix srepl helper for restore file snapshots --- backend/src/app/srepl/main.clj | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index 6914ff54d..e55a0bfdc 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -337,14 +337,23 @@ (db/tx-run! main/system fsnap/create-file-snapshot! {:file-id file-id :label label}))) (defn restore-file-snapshot! - [file-id label] - (let [file-id (h/parse-uuid file-id)] + [file-id & {:keys [label id]}] + (let [file-id (h/parse-uuid file-id) + snapshot-id (some-> id h/parse-uuid)] (db/tx-run! main/system (fn [{:keys [::db/conn] :as system}] - (when-let [snapshot (->> (h/search-file-snapshots conn #{file-id} label) - (map :id) - (first))] - (fsnap/restore-file-snapshot! system file-id (:id snapshot))))))) + (cond + (uuid? snapshot-id) + (fsnap/restore-file-snapshot! system file-id snapshot-id) + + (string? label) + (->> (h/search-file-snapshots conn #{file-id} label) + (map :id) + (first) + (fsnap/restore-file-snapshot! system file-id)) + + :else + (throw (ex-info "snapshot id or label should be provided" {}))))))) (defn list-file-snapshots! [file-id & {:as _}]