From 0ad555879127d58d6e89b5b00583f62c02f17e55 Mon Sep 17 00:00:00 2001 From: Mega Yu Date: Sat, 31 Jan 2026 16:54:47 +0800 Subject: [PATCH] compatible with windows path & support zotero path can be relative for ci testing --- .../src/logseq/graph_parser/exporter.cljs | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs index 3e24e3ccbc..3bf25e9c39 100644 --- a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs @@ -934,7 +934,7 @@ (when (and link id label) (when-let [zotero-data-dir (get-in config [:zotero/settings-v2 "default" :zotero-data-directory])] {:link (str "zotero://" link) - :path (node-path/join zotero-data-dir "storage" id label) + :path (path/path-join zotero-data-dir "storage" id label) :base label}))))) (defn- walk-ast-blocks @@ -1245,10 +1245,10 @@ (defn- build-pdf-annotations-tx "Builds tx for pdf annotations when a pdf has an annotations EDN file under assets/" [parent-asset-path assets parent-asset pdf-annotation-pages opts] - (let [asset-edn-path (path/path-normalize - (node-path/join common-config/local-assets-dir - (safe-sanitize-file-name - (node-path/basename (string/replace-first parent-asset-path #"(?i)\.pdf$" ".edn"))))) + (let [asset-edn-path (path/path-join + common-config/local-assets-dir + (safe-sanitize-file-name + (node-path/basename (string/replace-first parent-asset-path #"(?i)\.pdf$" ".edn")))) asset-md-name (str "hls__" (safe-sanitize-file-name (node-path/basename (string/replace-first parent-asset-path #"(?i)\.pdf$" ".md"))))] (when-let [asset-edn-map (get @assets asset-edn-path)] @@ -1324,7 +1324,7 @@ (when-let [metadata (not-empty (common-util/safe-read-map-string (:metadata (second asset-link))))] {:logseq.property.asset/resize-metadata metadata})) pdf-annotations-path (if (and zotero-asset? (string? asset-name)) - (node-path/join common-config/local-assets-dir asset-name) + (path/path-join common-config/local-assets-dir asset-name) (or asset-name asset-link-or-name)) pdf-annotations-tx (when (= "pdf" (path/file-ext pdf-annotations-path)) (build-pdf-annotations-tx pdf-annotations-path assets new-asset pdf-annotation-pages opts)) @@ -2040,6 +2040,22 @@ :level :error :ex-data {:error error}})))))) +(defn- resolve-zotero-config-path + [config config-file] + (let [config-path (:path config-file) + base-dir (when (and (string? config-path) + (node-path/isAbsolute config-path)) + ;; config.edn lives in /logseq/config.edn + (node-path/dirname (node-path/dirname config-path))) + to-abs (fn [p] + (if (and base-dir (string? p) (not (string/blank? p)) (not (node-path/isAbsolute p))) + (path/path-join base-dir p) + p))] + (run! prn ["resolve-zotero-config-path" config-file config-path base-dir]) + (-> config + (update-in [:zotero/settings-v2 "default" :zotero-data-directory] to-abs) + (update-in [:zotero/settings-v2 "default" :zotero-linked-attachment-base-directory] to-abs)))) + (defn export-config-file "Exports logseq/config.edn by saving to database and setting any properties related to config" [repo-or-conn config-file