|
892 | 892 | ;; {:url ["Complex" {:protocol "zotero", :link "select/library/items/6VCW9QFJ"}], :label [["Plain" "Dechow and Struppa - 2015 - Intertwingled.pdf"]], :full_text "[Dechow and Struppa - 2015 - Intertwingled.pdf](zotero://select/library/items/6VCW9QFJ)", :metadata ""} |
893 | 893 | (defn- get-zotero-local-pdf-path |
894 | 894 | [config m] |
895 | | - (let [link (:link (second (:url m))) |
896 | | - label (second (first (:label m))) |
897 | | - id (last (string/split link #"/"))] |
898 | | - (when (and link id label) |
899 | | - (when-let [zotero-data-dir (get-in config [:zotero/settings-v2 "default" :zotero-data-directory])] |
900 | | - {:link (str "zotero://" link) |
901 | | - :path (node-path/join zotero-data-dir "storage" id label) |
902 | | - :base label})))) |
| 895 | + (when (= "zotero" (:protocol (second (:url m)))) |
| 896 | + (let [link (:link (second (:url m))) |
| 897 | + label (second (first (:label m))) |
| 898 | + id (last (string/split link #"/"))] |
| 899 | + (when (and link id label) |
| 900 | + (when-let [zotero-data-dir (get-in config [:zotero/settings-v2 "default" :zotero-data-directory])] |
| 901 | + {:link (str "zotero://" link) |
| 902 | + :path (node-path/join zotero-data-dir "storage" id label) |
| 903 | + :base label}))))) |
903 | 904 |
|
904 | 905 | (defn- walk-ast-blocks |
905 | 906 | "Walks each ast block in order to its full depth. Saves multiple ast types for |
|
1048 | 1049 | "Given an asset's relative or full path, create a unique name for identifying an asset. |
1049 | 1050 | Must handle to paths as ../assets/*, assets/* and with subdirectories" |
1050 | 1051 | [path] |
1051 | | - (or (re-find #"assets/.*$" path) |
1052 | | - ;; pdf outside logseq graphs |
1053 | | - (when (string/ends-with? path ".pdf") |
1054 | | - path))) |
| 1052 | + (when (string? path) |
| 1053 | + (or (re-find #"assets/.*$" path) |
| 1054 | + ;; pdf outside logseq graphs |
| 1055 | + (when (string/ends-with? path ".pdf") |
| 1056 | + path)))) |
1055 | 1057 |
|
1056 | 1058 | (defn- update-asset-links-in-block-title [block-title asset-name-to-uuids ignored-assets] |
1057 | 1059 | (reduce (fn [acc [asset-name asset-uuid]] |
|
1213 | 1215 | (p/let [asset-maps* (p/all (map |
1214 | 1216 | (fn [asset-link] |
1215 | 1217 | (p/let [path* (-> asset-link second :url second) |
| 1218 | + zotero-asset? (when (map? path*) |
| 1219 | + (= "zotero" (:protocol (second (:url (second asset-link)))))) |
1216 | 1220 | {:keys [path link base]} (if (map? path*) |
1217 | 1221 | (get-zotero-local-pdf-path user-config (second asset-link)) |
1218 | 1222 | {:path path*}) |
1219 | | - asset-name (-> path asset-path->name) |
1220 | | - asset-link-or-name (or link (-> path asset-path->name)) |
| 1223 | + asset-name (some-> path asset-path->name) |
| 1224 | + asset-link-or-name (or link (some-> path asset-path->name)) |
1221 | 1225 | asset-data* (when asset-link-or-name (get @assets asset-link-or-name)) |
1222 | 1226 | _ (when (and asset-link-or-name |
1223 | 1227 | (not asset-data*) |
|
1261 | 1265 | (swap! assets assoc-in [asset-link-or-name :asset-created?] true) |
1262 | 1266 | {:asset-name-uuid [asset-link-or-name (:block/uuid new-asset)] |
1263 | 1267 | :asset-tx asset-tx})) |
1264 | | - (do |
| 1268 | + (when-not zotero-asset? ; no need to report warning for zotero managed pdf files |
1265 | 1269 | (swap! ignored-assets conj |
1266 | 1270 | {:reason "No asset data found for this asset path" |
1267 | 1271 | :path (-> asset-link second :url second) |
|
0 commit comments