浏览代码

fix: assets not copied for import

Caused by a commit yesterday. Also removed unused
import-file-to-db-graph options
Gabriel Horner 1 年之前
父节点
当前提交
b6a952fd7d
共有 2 个文件被更改,包括 7 次插入10 次删除
  1. 3 8
      deps/graph-parser/src/logseq/graph_parser.cljs
  2. 4 2
      src/main/frontend/components/imports.cljs

+ 3 - 8
deps/graph-parser/src/logseq/graph_parser.cljs

@@ -199,9 +199,7 @@ Options available:
 
 
 (defn import-file-to-db-graph
 (defn import-file-to-db-graph
   "Parse file and save parsed data to the given db graph."
   "Parse file and save parsed data to the given db graph."
-  [conn file content {:keys [delete-blocks-fn extract-options skip-db-transact?]
-                      :or {delete-blocks-fn (constantly [])
-                           skip-db-transact? false}
+  [conn file content {:keys [extract-options]
                       :as options}]
                       :as options}]
   (let [format (common-util/get-format file)
   (let [format (common-util/get-format file)
         {:keys [tx ast]}
         {:keys [tx ast]}
@@ -227,7 +225,6 @@ Options available:
               ;; remove file path relative
               ;; remove file path relative
               pages (map #(dissoc % :block/file :block/properties) pages)
               pages (map #(dissoc % :block/file :block/properties) pages)
               block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
               block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
-              delete-blocks (delete-blocks-fn @conn (first pages) file block-ids)
               block-refs-ids (->> (mapcat :block/refs blocks)
               block-refs-ids (->> (mapcat :block/refs blocks)
                                   (filter (fn [ref] (and (vector? ref)
                                   (filter (fn [ref] (and (vector? ref)
                                                          (= :block/uuid (first ref)))))
                                                          (= :block/uuid (first ref)))))
@@ -263,12 +260,10 @@ Options available:
               blocks (map #(update-imported-block conn %) blocks)
               blocks (map #(update-imported-block conn %) blocks)
               pages-index (map #(select-keys % [:block/name]) pages)]
               pages-index (map #(select-keys % [:block/name]) pages)]
 
 
-          {:tx (concat refs whiteboard-pages pages-index delete-blocks pages block-ids blocks)
+          {:tx (concat refs whiteboard-pages pages-index pages block-ids blocks)
            :ast ast})
            :ast ast})
         tx' (common-util/fast-remove-nils tx)
         tx' (common-util/fast-remove-nils tx)
-        result (if skip-db-transact?
-                 tx'
-                 (d/transact! conn tx' (select-keys options [:new-graph? :from-disk?])))]
+        result (d/transact! conn tx' (select-keys options [:new-graph? :from-disk?]))]
     {:tx-report result
     {:tx-report result
      :ast ast}))
      :ast ast}))
 
 

+ 4 - 2
src/main/frontend/components/imports.cljs

@@ -344,9 +344,11 @@
         original-graph-name (string/replace (.-webkitRelativePath (first file-objs)) #"/.*" "")
         original-graph-name (string/replace (.-webkitRelativePath (first file-objs)) #"/.*" "")
         import-graph-fn (fn [graph-name]
         import-graph-fn (fn [graph-name]
                           (let [files (->> file-objs
                           (let [files (->> file-objs
-                                           (remove #(fs-util/ignored-path? original-graph-name (.-webkitRelativePath %)))
                                            (map #(hash-map :file-object %
                                            (map #(hash-map :file-object %
-                                                           :rpath (path/trim-dir-prefix original-graph-name (.-webkitRelativePath %)))))]
+                                                           :rpath (path/trim-dir-prefix original-graph-name (.-webkitRelativePath %))))
+                                           (remove #(and (not (string/starts-with? (:rpath %) "assets/"))
+                                                         ;; TODO: Update this when supporting more formats as this agressively excludes most formats
+                                                         (fs-util/ignored-path? original-graph-name (.-webkitRelativePath (:file-object %))))))]
                             (if-let [config-file (first (filter #(= (:rpath %) "logseq/config.edn") files))]
                             (if-let [config-file (first (filter #(= (:rpath %) "logseq/config.edn") files))]
                               (import-file-graph files graph-name config-file)
                               (import-file-graph files graph-name config-file)
                               (notification/show! "Import failed as the file 'logseq/config.edn' was not found for a Logseq graph."
                               (notification/show! "Import failed as the file 'logseq/config.edn' was not found for a Logseq graph."