|
@@ -137,6 +137,22 @@
|
|
|
new-fpath (path/path-join repo-dir new-path)]
|
|
|
(protocol/rename! (get-fs old-fpath) repo old-fpath new-fpath)))))
|
|
|
|
|
|
+(defn stat
|
|
|
+ ([fpath]
|
|
|
+ (protocol/stat (get-fs fpath) fpath))
|
|
|
+ ([dir path]
|
|
|
+ (let [fpath (path/path-join dir path)]
|
|
|
+ (protocol/stat (get-fs dir) fpath))))
|
|
|
+
|
|
|
+(defn mkdir-if-not-exists
|
|
|
+ [dir]
|
|
|
+ (when dir
|
|
|
+ (util/p-handle
|
|
|
+ (stat dir)
|
|
|
+ (fn [_stat])
|
|
|
+ (fn [_error]
|
|
|
+ (mkdir-recur! dir)))))
|
|
|
+
|
|
|
(defn copy!
|
|
|
"Only used by Logseq Sync"
|
|
|
[repo old-path new-path]
|
|
@@ -149,15 +165,13 @@
|
|
|
(map #(if (or (util/electron?) (mobile-util/native-platform?))
|
|
|
%
|
|
|
(str (config/get-repo-dir repo) "/" %))
|
|
|
- [old-path new-path])]
|
|
|
- (protocol/copy! (get-fs old-path) repo old-path new-path))))
|
|
|
+ [old-path new-path])
|
|
|
+ new-dir (path/dirname new-path)]
|
|
|
+ (p/do!
|
|
|
+ (mkdir-if-not-exists new-dir)
|
|
|
+ (protocol/copy! (get-fs old-path) repo old-path new-path)))))
|
|
|
+
|
|
|
|
|
|
-(defn stat
|
|
|
- ([fpath]
|
|
|
- (protocol/stat (get-fs fpath) fpath))
|
|
|
- ([dir path]
|
|
|
- (let [fpath (path/path-join dir path)]
|
|
|
- (protocol/stat (get-fs dir) fpath))))
|
|
|
|
|
|
(defn open-dir
|
|
|
[dir]
|
|
@@ -192,15 +206,6 @@
|
|
|
[dir]
|
|
|
(protocol/unwatch-dir! (get-fs dir) dir))
|
|
|
|
|
|
-(defn mkdir-if-not-exists
|
|
|
- [dir]
|
|
|
- (when dir
|
|
|
- (util/p-handle
|
|
|
- (stat dir)
|
|
|
- (fn [_stat])
|
|
|
- (fn [_error]
|
|
|
- (mkdir! dir)))))
|
|
|
-
|
|
|
;; FIXME: counterintuitive return value
|
|
|
(defn create-if-not-exists
|
|
|
"Create a file if it doesn't exist. return false on written, true on already exists"
|