fix: can't create files (assets/draws) on browser

Fixes LOG-2908
This commit is contained in:
Tienson Qin
2023-11-22 23:17:22 +08:00
parent 44617ab8ca
commit 265fccd6bc
2 changed files with 8 additions and 6 deletions

View File

@@ -51,11 +51,13 @@
(let [fpath (path/url-to-path dir)]
(-> (js/window.pfs.mkdir fpath)
(p/catch (fn [error] (println "(memory-fs)Mkdir error: " error)))))))
(mkdir-recur! [_this dir]
(mkdir-recur! [this dir]
;; FIXME: replace this with a recurisve implementation
(when js/window.pfs
(let [fpath (path/url-to-path dir)]
(-> (js/window.pfs.mkdir fpath #js {:recursive true})
(p/catch (fn [error] (println "(memory-fs)Mkdir-recur error: " error)))))))
(p/let [dir' (path/url-to-path dir)
parent (path/parent dir')
_ (when parent (<ensure-dir! parent))]
(protocol/mkdir! this dir'))))
(readdir [_this dir]
(when js/window.pfs

View File

@@ -1454,8 +1454,8 @@
(config/db-based-graph? (state/get-current-repo)) ; memory fs
(p/let [binary (fs/read-file repo-dir path {})
blob (js/Blob. (array binary) (clj->js {:type "image"}))]
(when blob (js/URL.createObjectURL blob)))
blob (js/Blob. (array binary) (clj->js {:type "image"}))]
(when blob (js/URL.createObjectURL blob)))
:else ;; nfs
(let [handle-path (str "handle/" full-path)