mirror of
https://github.com/penpot/penpot.git
synced 2025-04-30 11:46:20 +02:00
🐛 Fix srepl helper for restore file snapshots (#6300)
This commit is contained in:
parent
eee5cf5fb4
commit
7990400c7a
1 changed files with 15 additions and 6 deletions
|
@ -337,14 +337,23 @@
|
||||||
(db/tx-run! main/system fsnap/create-file-snapshot! {:file-id file-id :label label})))
|
(db/tx-run! main/system fsnap/create-file-snapshot! {:file-id file-id :label label})))
|
||||||
|
|
||||||
(defn restore-file-snapshot!
|
(defn restore-file-snapshot!
|
||||||
[file-id label]
|
[file-id & {:keys [label id]}]
|
||||||
(let [file-id (h/parse-uuid file-id)]
|
(let [file-id (h/parse-uuid file-id)
|
||||||
|
snapshot-id (some-> id h/parse-uuid)]
|
||||||
(db/tx-run! main/system
|
(db/tx-run! main/system
|
||||||
(fn [{:keys [::db/conn] :as system}]
|
(fn [{:keys [::db/conn] :as system}]
|
||||||
(when-let [snapshot (->> (h/search-file-snapshots conn #{file-id} label)
|
(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)
|
(map :id)
|
||||||
(first))]
|
(first)
|
||||||
(fsnap/restore-file-snapshot! system file-id (:id snapshot)))))))
|
(fsnap/restore-file-snapshot! system file-id))
|
||||||
|
|
||||||
|
:else
|
||||||
|
(throw (ex-info "snapshot id or label should be provided" {})))))))
|
||||||
|
|
||||||
(defn list-file-snapshots!
|
(defn list-file-snapshots!
|
||||||
[file-id & {:as _}]
|
[file-id & {:as _}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue