Make sure file paths are normalized before writing

This commit is contained in:
Tienson Qin
2022-11-18 12:55:30 +08:00
parent 671ca3bc13
commit 831356ece8
2 changed files with 17 additions and 13 deletions

View File

@@ -76,7 +76,8 @@
(defn write-file!
[repo dir path content opts]
(when content
(let [fs-record (get-fs dir)]
(let [path (gp-util/path-normalize path)
fs-record (get-fs dir)]
(->
(p/let [opts (assoc opts
:error-handler
@@ -111,18 +112,19 @@
(defn rename!
[repo old-path new-path]
(cond
(let [new-path (gp-util/path-normalize new-path)]
(cond
; See https://github.com/isomorphic-git/lightning-fs/issues/41
(= old-path new-path)
(p/resolved nil)
(= old-path new-path)
(p/resolved nil)
:else
(let [[old-path new-path]
(map #(if (or (util/electron?) (mobile-util/native-platform?))
%
(str (config/get-repo-dir repo) "/" %))
[old-path new-path])]
(protocol/rename! (get-fs old-path) repo old-path new-path))))
:else
(let [[old-path new-path]
(map #(if (or (util/electron?) (mobile-util/native-platform?))
%
(str (config/get-repo-dir repo) "/" %))
[old-path new-path])]
(protocol/rename! (get-fs old-path) repo old-path new-path)))))
(defn copy!
[repo old-path new-path]