Skip to content

Commit

Permalink
fix: p/catch should handle outer error
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk authored and tiensonqin committed Dec 11, 2020
1 parent 92e791e commit fbc69d5
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/main/frontend/fs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@
(local-db? dir)
(let [[root new-dir] (rest (string/split dir "/"))
root-handle (str "handle/" root)]
(p/let [handle (idb/get-item root-handle)
_ (when handle (utils/verifyPermission handle true))]
(when (and handle new-dir
(not (string/blank? new-dir)))
(-> (p/let [handle (.getDirectoryHandle ^js handle new-dir
#js {:create true})
handle-path (str root-handle "/" new-dir)
_ (idb/set-item! handle-path handle)]
(add-nfs-file-handle! handle-path handle)
(println "Stored handle: " (str root-handle "/" new-dir)))
(p/catch (fn [error]
(println "mkdir error: " error ", dir: " dir)
(js/console.error error)))))))
(->
(p/let [handle (idb/get-item root-handle)
_ (when handle (utils/verifyPermission handle true))]
(when (and handle new-dir
(not (string/blank? new-dir)))
(p/let [handle (.getDirectoryHandle ^js handle new-dir
#js {:create true})
handle-path (str root-handle "/" new-dir)
_ (idb/set-item! handle-path handle)]
(add-nfs-file-handle! handle-path handle)
(println "Stored handle: " (str root-handle "/" new-dir)))))
(p/catch (fn [error]
(println "mkdir error: " error ", dir: " dir)
(js/console.error error)))))

(and dir js/window.pfs)
(js/window.pfs.mkdir dir)
Expand Down

0 comments on commit fbc69d5

Please sign in to comment.