소스 검색

fix: file graph import

Tienson Qin 1 개월 전
부모
커밋
7dc155b28b

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

@@ -1791,7 +1791,7 @@
         (split-pages-and-properties-tx pages-tx old-properties existing-pages (:import-state options) @(:upstream-properties tx-options))
         ;; _ (when (seq property-pages-tx) (cljs.pprint/pprint {:property-pages-tx property-pages-tx}))
         ;; Necessary to transact new property entities first so that block+page properties can be transacted next
-        main-props-tx-report (ldb/transact! conn property-pages-tx {::new-graph? true ::path file})
+        main-props-tx-report (d/transact! conn property-pages-tx {::new-graph? true ::path file})
         _ (save-from-tx property-pages-tx options)
 
         classes-tx @(:classes-tx tx-options)
@@ -1817,13 +1817,13 @@
         ;;                        [:whiteboard-pages :pages-index :page-properties-tx :property-page-properties-tx :pages-tx' :classes-tx :blocks-index :blocks-tx]
         ;;                        [whiteboard-pages pages-index page-properties-tx property-page-properties-tx pages-tx' classes-tx blocks-index blocks-tx]))
         ;; _ (when (not (seq whiteboard-pages)) (cljs.pprint/pprint {#_:property-pages-tx #_property-pages-tx :pages-tx pages-tx :tx tx'}))
-        main-tx-report (ldb/transact! conn tx' {::new-graph? true ::path file})
+        main-tx-report (d/transact! conn tx' {::new-graph? true ::path file})
         _ (save-from-tx tx' options)
 
         upstream-properties-tx
         (build-upstream-properties-tx @conn @(:upstream-properties tx-options) (:import-state options) log-fn)
         ;; _ (when (seq upstream-properties-tx) (cljs.pprint/pprint {:upstream-properties-tx upstream-properties-tx}))
-        upstream-tx-report (when (seq upstream-properties-tx) (ldb/transact! conn upstream-properties-tx {::new-graph? true ::path file}))
+        upstream-tx-report (when (seq upstream-properties-tx) (d/transact! conn upstream-properties-tx {::new-graph? true ::path file}))
         _ (save-from-tx upstream-properties-tx options)]
 
     ;; Return all tx-reports that occurred in this fn as UI needs to know what changed

+ 1 - 1
deps/outliner/src/logseq/outliner/db_pipeline.cljs

@@ -12,7 +12,7 @@
   "Modified copy of frontend.worker.pipeline/invoke-hooks that handles new DB graphs but
    doesn't handle updating DB graphs well yet e.g. doesn't handle :block/tx-id"
   [conn tx-report]
-  (when-not (:pipeline-replace? (:tx-meta tx-report))
+  (when-not (:transact-new-graph-refs? (:tx-meta tx-report))
     ;; TODO: Handle block edits with separate :block/refs rebuild as deleting property values is buggy
     (outliner-pipeline/transact-new-db-graph-refs conn tx-report)))
 

+ 1 - 1
deps/outliner/src/logseq/outliner/pipeline.cljs

@@ -147,5 +147,5 @@
   (let [{:keys [blocks]} (ds-report/get-blocks-and-pages tx-report)
         refs-tx-report (when-let [refs-tx (and (seq blocks) (rebuild-block-refs-tx tx-report blocks))]
                          (ldb/transact! conn refs-tx (-> (:tx-meta tx-report)
-                                                         (assoc :pipeline-replace? true))))]
+                                                         (assoc :transact-new-graph-refs? true))))]
     refs-tx-report))

+ 10 - 9
src/main/frontend/worker/pipeline.cljs

@@ -431,14 +431,15 @@
 
 (defn invoke-hooks
   [repo conn {:keys [tx-meta] :as tx-report} context]
-  (let [{:keys [from-disk? new-graph?]} tx-meta]
-    (cond
-      (or from-disk? new-graph?)
-      {:tx-report tx-report}
+  (let [{:keys [from-disk? new-graph? transact-new-graph-refs?]} tx-meta]
+    (when-not transact-new-graph-refs?
+      (cond
+        (or from-disk? new-graph?)
+        {:tx-report tx-report}
 
-      (or (::gp-exporter/new-graph? tx-meta)
-          (and (::sqlite-export/imported-data? tx-meta) (:import-db? tx-meta)))
-      (invoke-hooks-for-imported-graph conn tx-report)
+        (or (::gp-exporter/new-graph? tx-meta)
+            (and (::sqlite-export/imported-data? tx-meta) (:import-db? tx-meta)))
+        (invoke-hooks-for-imported-graph conn tx-report)
 
-      :else
-      (invoke-hooks-default repo conn tx-report context))))
+        :else
+        (invoke-hooks-default repo conn tx-report context)))))