enhance: CLI imports assets as #Asset

Had to split assets into two steps now that asset naming is dependent
on uuids. Also add explicit asserts in exporter to catch silent
failure in tests
This commit is contained in:
Gabriel Horner
2025-06-11 10:36:03 -04:00
committed by Tienson Qin
parent 63b75dfab7
commit 38734bde40
6 changed files with 170 additions and 36 deletions

View File

@@ -27,6 +27,7 @@
[goog.object :as gobj]
[lambdaisland.glogi :as log]
[logseq.common.path :as path]
[logseq.db.frontend.asset :as db-asset]
[logseq.db.frontend.validate :as db-validate]
[logseq.graph-parser.exporter :as gp-exporter]
[logseq.shui.dialog.core :as shui-dialog]
@@ -338,8 +339,15 @@
(log/error :import-error ex-data)))
(notification/show! msg :warning false)))
;; TODO: Wire up UI
(defn- copy-asset [repo repo-dir file]
;; (prn ::copy-asset (:path file))
;; (prn ::size (.-size (:file-object file)))
(-> (.arrayBuffer (:file-object file))
#_(p/then (fn [buffer]
(p/let [checksum (db-asset/<get-file-array-buffer-checksum buffer)]
(prn ::checksum2 checksum)
buffer)))
(p/then (fn [buffer]
(let [content (js/Uint8Array. buffer)
parent-dir (path/path-join repo-dir (path/dirname (:path file)))]