use external-file-name instead of adding new property

This commit is contained in:
Mega Yu
2026-01-27 20:42:11 +08:00
parent 45ebb9e000
commit f481c1b6bc
4 changed files with 18 additions and 23 deletions

View File

@@ -532,16 +532,12 @@
:hide? false
:public? true}
:queryable? true}
;; need to rename for better alignment with practical purposes
:logseq.property.asset/external-file-name {:title "External file name"
:schema {:type :string
:hide? true
:public? false}
:queryable? false}
:logseq.property.asset/external-props {:title "External properties"
:schema {:type :map
:hide? true
:public? false}
:queryable? false}
:logseq.property.asset/size {:title "File Size"
:schema {:type :raw-number
:hide? true

View File

@@ -1288,18 +1288,18 @@
(and zotero-asset? asset-name) (string/replace path #"[^/]+$" asset-name)
:else path)
asset-link-or-name (or link asset-name)
external-props (when zotero-asset?
(if linked-path
{:zotero-linked-file linked-relative}
{:zotero-imported-file (string/join ns-util/namespace-char [(last (string/split link #"/")) asset-name])}))]
asset-path (when zotero-asset?
(if linked-path
(str "zotero-link://" linked-relative)
(str "zotero-path://" (string/join ns-util/namespace-char [(last (string/split link #"/")) asset-name]))))]
{:asset-link-or-name asset-link-or-name
:asset-name asset-name
:external-props external-props
:asset-path asset-path
:path path
:zotero-asset? zotero-asset?}))
(defn- ensure-asset-data!
[assets asset-link-or-name path asset-name external-props <get-file-stat]
[assets asset-link-or-name path asset-path <get-file-stat]
(when (and asset-link-or-name
(not (get @assets asset-link-or-name))
(string/ends-with? path ".pdf")
@@ -1312,8 +1312,7 @@
:checksum "0000000000000000000000000000000000000000000000000000000000000000"
:size (.-size stat)
:external-url (or asset-link-or-name path)
:external-file-name asset-name
:external-props external-props}))
:external-file-name asset-path}))
(p/catch (fn [error]
(js/console.error error))))))
@@ -1346,9 +1345,9 @@
(if (seq asset-links)
(p/let [asset-maps* (p/all (map
(fn [asset-link]
(p/let [{:keys [asset-link-or-name asset-name external-props path zotero-asset?]}
(p/let [{:keys [asset-link-or-name asset-name asset-path path zotero-asset?]}
(resolve-asset-data asset-link user-config linked-files linked-base-dir zotero-imported-files)
_ (ensure-asset-data! assets asset-link-or-name path asset-name external-props <get-file-stat)
_ (ensure-asset-data! assets asset-link-or-name path asset-path <get-file-stat)
asset-data (when asset-link-or-name (get @assets asset-link-or-name))]
(if asset-data
(cond

View File

@@ -199,13 +199,14 @@
:owner-window (pdf-windows/resolve-own-window viewer)))))
(defn- get-zotero-local-pdf-path
[{:keys [zotero-linked-file zotero-imported-file]}]
[path]
(let [zotero-config (get-in (state/sub-config) [:zotero/settings-v2 "default"])
zotero-data-directory (:zotero-data-directory zotero-config)
zotero-linked-attachment-base-directory (:zotero-linked-attachment-base-directory zotero-config)]
(if zotero-linked-file
(str zotero-linked-attachment-base-directory "/" zotero-linked-file)
(str zotero-data-directory "/storage/" zotero-imported-file))))
zotero-linked-attachment-base-directory (:zotero-linked-attachment-base-directory zotero-config)
relative-path (subs path 14)]
(if (string/starts-with? path "zotero-link://")
(str zotero-linked-attachment-base-directory "/" relative-path)
(str zotero-data-directory "/storage/" relative-path))))
(defn db-based-open-block-ref!
[block]
@@ -214,7 +215,7 @@
external-url (:logseq.property.asset/external-url asset)
file-path (or external-url (str "../assets/" (:block/uuid asset) ".pdf"))
file-path (if (string/starts-with? file-path "zotero://")
(get-zotero-local-pdf-path (:logseq.property.asset/external-props asset))
(get-zotero-local-pdf-path (:logseq.property.asset/external-file-name asset))
file-path)]
(if asset
(->

View File

@@ -186,8 +186,7 @@
["65.17" {:properties [:logseq.property.publish/published-url]}]
["65.18" {:fix deprecated-ensure-graph-uuid}]
["65.19" {:properties [:logseq.property/choice-classes :logseq.property/choice-exclusions]}]
["65.20" {:properties [:logseq.property.class/bidirectional-property-title :logseq.property.class/enable-bidirectional?]}]
["65.21" {:properties [:logseq.property.asset/external-props]}]])
["65.20" {:properties [:logseq.property.class/bidirectional-property-title :logseq.property.class/enable-bidirectional?]}]])
(let [[major minor] (last (sort (map (comp (juxt :major :minor) db-schema/parse-schema-version first)
schema-version->updates)))]