diff --git a/src/main/frontend/handler/file_sync.cljs b/src/main/frontend/handler/file_sync.cljs index 4dee79f10c..6a4f9b30f9 100644 --- a/src/main/frontend/handler/file_sync.cljs +++ b/src/main/frontend/handler/file_sync.cljs @@ -16,7 +16,8 @@ [cljs-time.coerce :as tc] [cljs-time.core :as t] [frontend.storage :as storage] - [lambdaisland.glogi :as log])) + [lambdaisland.glogi :as log] + [logseq.common.path :as path])) (def *beta-unavailable? (volatile! false)) @@ -130,19 +131,16 @@ [:div "Downloaded version file at: "] [:div key]] :success false))) (when-not (instance? ExceptionInfo r) - (node-path/join "logseq" "version-files" key)))))) + (path/path-join "logseq" "version-files" key)))))) (defn- page :block/file :file/path)] - (let [base-path (config/get-repo-dir (state/get-current-repo)) - rel-path (string/replace-first path base-path "") - version-files-dir (->> (node-path/join "logseq/version-files/local" rel-path) - node-path/parse - (#(js->clj % :keywordize-keys true)) - ((juxt :dir :name)) - (apply node-path/join base-path)) + (let [base-path (config/get-repo-dir (state/get-current-repo)) + rel-path (string/replace-first path base-path "") + file-stem (path/file-stem rel-path) + version-files-dir (path/path-join base-path "logseq/version-files/local" (path/dirname rel-path) file-stem) version-file-paths (c (fs/readdir version-files-dir :path-only? true)))] (when-not (instance? ExceptionInfo version-file-paths) (when (seq version-file-paths) @@ -155,7 +153,9 @@ (js->clj :keywordize-keys true) :name (#(tf/parse (tf/formatter "yyyy-MM-dd'T'HH_mm_ss.SSSZZ") %)))] - {:create-time create-time :path path :relative-path (string/replace-first path base-path "")}) + {:create-time create-time + :path path + :relative-path (path/relative-path base-path path)}) (catch :default e (log/error :page-history/parse-format-error e) nil))) diff --git a/src/main/frontend/util/fs.cljs b/src/main/frontend/util/fs.cljs index d43ef9d597..2c60ced9e5 100644 --- a/src/main/frontend/util/fs.cljs +++ b/src/main/frontend/util/fs.cljs @@ -69,9 +69,9 @@ [])) (defn read-repo-file - [repo-url file] + [repo-url file-rpath] (when-let [repo-dir (config/get-repo-dir repo-url)] - (fs/read-file repo-dir file))) + (fs/read-file repo-dir file-rpath))) (def multiplatform-reserved-chars ":\\*\\?\"<>|\\#\\\\")