Skip to content

Commit

Permalink
fix: fix concurrency bug in create-if-not-exists (logseq#884)
Browse files Browse the repository at this point in the history
Co-authored-by: Tienson Qin <[email protected]>
  • Loading branch information
gyk and tiensonqin authored Dec 10, 2020
1 parent 6828078 commit 395cdd6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/frontend/fs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,13 @@
(let [path (if (util/starts-with? path "/")
path
(str "/" path))]
(util/p-handle
(stat dir path)
(fn [_stat] true)
(fn [error]
(write-file repo dir path initial-content)
false)))))
(->
(p/let [_ (stat dir path)]
true)
(p/catch
(fn [_error]
(p/let [_ (write-file repo dir path initial-content)]
false)))))))

(defn file-exists?
[dir path]
Expand Down

0 comments on commit 395cdd6

Please sign in to comment.