fix: force /private part on iOS

pull/7280/head
Tienson Qin 2022-11-09 20:18:30 +08:00
parent 1bfb7321ec
commit d801c96a52
2 changed files with 10 additions and 5 deletions

View File

@ -212,10 +212,13 @@
(error-handler error)
(log/error :write-file-failed error)))))))))
(defn remove-private-part
"iOS sometimes return the private part."
(defn ios-force-include-private
"iOS sometimes return paths without the private part."
[path]
(string/replace path "///private/" "///"))
(if (string/includes? path "///private/")
path
(let [[prefix others] (string/split path "///")]
(str prefix "///private/" others))))
(defn normalize-file-protocol-path [dir path]
(let [dir (some-> dir (string/replace #"/+$" ""))
@ -249,7 +252,9 @@
:else
(let [path' (safe-encode-url path)]
(str dir "/" path')))]
(remove-private-part path')))
(if (mobile-util/native-ios?)
(ios-force-include-private path')
path')))
(defn- local-container-path?
"Check whether `path' is logseq's container `localDocumentsPath' on iOS"

View File

@ -570,7 +570,7 @@
payload (-> event
(js->clj :keywordize-keys true)
(update :path (fn [path]
(when (string? path) (capacitor-fs/remove-private-part path)))))]
(when (string? path) (capacitor-fs/ios-force-include-private path)))))]
(fs-watcher/handle-changed! type payload)
(when (file-sync-handler/enable-sync?)
(sync/file-watch-handler type payload))))