mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 22:49:53 +00:00
use ldb/transact! instead of d/transact!
This commit is contained in:
@@ -86,12 +86,7 @@
|
||||
(transact! repo tx-data nil))
|
||||
([repo tx-data tx-meta]
|
||||
(when-let [conn (get-db repo false)]
|
||||
;; (prn :debug "DB transact:")
|
||||
;; (frontend.util/pprint {:tx-data tx-data
|
||||
;; :tx-meta tx-meta})
|
||||
(if tx-meta
|
||||
(d/transact! conn (vec tx-data) tx-meta)
|
||||
(d/transact! conn (vec tx-data))))))
|
||||
(ldb/transact! conn tx-data tx-meta))))
|
||||
|
||||
(defn start!
|
||||
([repo]
|
||||
|
||||
@@ -341,7 +341,8 @@ independent of format as format specific heading characters are stripped"
|
||||
{:query-fn (fn [_]
|
||||
(let [e (db-utils/entity id)
|
||||
children (map :db/id (sort-by-left (:block/_parent e) e))]
|
||||
[e {:original-name (:block/original-name e)
|
||||
[e {:name (:block/name e)
|
||||
:original-name (:block/original-name e)
|
||||
:link (:block/link e)
|
||||
:namespace (:block/namespace e)
|
||||
:types (:block/type e)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
[logseq.graph-parser.whiteboard :as gp-whiteboard]
|
||||
[frontend.worker.handler.page :as worker-page]
|
||||
[frontend.worker.state :as worker-state]
|
||||
[logseq.db :as ldb]
|
||||
|
||||
[frontend.db.rtc.const :as rtc-const]
|
||||
[frontend.db.rtc.op-mem-layer :as op-mem-layer]
|
||||
@@ -110,12 +111,12 @@
|
||||
(apply outliner-core/save-block! args)))
|
||||
|
||||
(defmethod transact-db! :delete-whiteboard-blocks [_ conn block-uuids]
|
||||
(d/transact! conn
|
||||
(mapv (fn [block-uuid] [:db/retractEntity [:block/uuid block-uuid]]) block-uuids)
|
||||
{:persist-op? false}))
|
||||
(ldb/transact! conn
|
||||
(mapv (fn [block-uuid] [:db/retractEntity [:block/uuid block-uuid]]) block-uuids)
|
||||
{:persist-op? false}))
|
||||
|
||||
(defmethod transact-db! :upsert-whiteboard-block [_ conn blocks]
|
||||
(d/transact! conn blocks {:persist-op? false}))
|
||||
(ldb/transact! conn blocks {:persist-op? false}))
|
||||
|
||||
(defn- whiteboard-page-block?
|
||||
[block]
|
||||
|
||||
@@ -90,19 +90,13 @@
|
||||
(->> (d/pull-many db selector eids)
|
||||
(map #(update-block-content % (:db/id %))))))))
|
||||
|
||||
(defn- actual-transact!
|
||||
[repo-url tx-data tx-meta]
|
||||
(let [tx-data (common-util/fast-remove-nils tx-data)]
|
||||
(when (seq tx-data)
|
||||
(conn/transact! repo-url tx-data tx-meta))))
|
||||
|
||||
(if config/publishing?
|
||||
(defn- transact!*
|
||||
[repo-url tx-data tx-meta]
|
||||
;; :save-block is for query-table actions like sorting and choosing columns
|
||||
(when (#{:collapse-expand-blocks :save-block} (:outliner-op tx-meta))
|
||||
(actual-transact! repo-url tx-data tx-meta)))
|
||||
(def transact!* actual-transact!))
|
||||
(conn/transact! repo-url tx-data tx-meta)))
|
||||
(def transact!* conn/transact!))
|
||||
|
||||
(defn transact!
|
||||
([tx-data]
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[frontend.worker.pipeline :as pipeline]
|
||||
[frontend.worker.state :as state]
|
||||
[frontend.worker.file :as file]))
|
||||
[frontend.worker.file :as file]
|
||||
[logseq.db :as ldb]))
|
||||
|
||||
(defonce *sqlite state/*sqlite)
|
||||
(defonce *sqlite-conns state/*sqlite-conns)
|
||||
@@ -258,7 +259,7 @@
|
||||
tx-meta' (if (or (:from-disk? tx-meta) (:new-graph? tx-meta))
|
||||
tx-meta
|
||||
(assoc tx-meta :skip-store? true))
|
||||
tx-report (d/transact! conn tx-data tx-meta')
|
||||
tx-report (ldb/transact! conn tx-data tx-meta')
|
||||
result (pipeline/invoke-hooks repo conn tx-report context)
|
||||
;; TODO: delay search indice so that UI can be refreshed earlier
|
||||
search-indice (search/sync-search-indice repo (:tx-report result))
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.db.utils :as db-utils]
|
||||
[frontend.util :as util]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[logseq.outliner.core :as outliner-core]
|
||||
@@ -65,13 +64,14 @@
|
||||
(when (and (db/page-exists? from-page-name)
|
||||
(db/page-exists? to-page-name)
|
||||
(not= from-page-name to-page-name))
|
||||
(let [to-page (db/entity [:block/name to-page-name])
|
||||
(let [conn (db/get-db false)
|
||||
to-page (db/entity [:block/name to-page-name])
|
||||
to-id (:db/id to-page)
|
||||
from-page (db/entity [:block/name from-page-name])
|
||||
from-id (:db/id from-page)
|
||||
from-first-child (some->> (db/pull from-id)
|
||||
(outliner-core/block (db/get-db))
|
||||
(otree/-get-down (db/get-db false))
|
||||
(outliner-core/block @conn)
|
||||
(#(otree/-get-down % conn))
|
||||
(outliner-core/get-data))
|
||||
to-last-direct-child-id (model/get-block-last-direct-child-id (db/get-db) to-id)
|
||||
repo (state/get-current-repo)
|
||||
@@ -148,5 +148,4 @@
|
||||
:uuid (:block/uuid page-e)
|
||||
:redirect? redirect?
|
||||
:create-first-block? false
|
||||
:persist-op? persist-op?}))
|
||||
(ui-handler/re-render-root!))))))
|
||||
:persist-op? persist-op?})))))))
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
(when (seq fix-conflicts-tx)
|
||||
(prn :debug :conflicts-tx)
|
||||
(pprint/pprint fix-conflicts-tx)
|
||||
(let [tx-data (:tx-data (d/transact! conn fix-conflicts-tx transact-opts))]
|
||||
(let [tx-data (:tx-data (ldb/transact! conn fix-conflicts-tx transact-opts))]
|
||||
(swap! *fix-tx-data (fn [old-data] (concat old-data tx-data))))
|
||||
(when (seq (get-conflicts @conn page-id))
|
||||
(loop-fix-conflicts conn page-id transact-opts *fix-tx-data)))))
|
||||
@@ -167,6 +167,6 @@
|
||||
parent-left->es' (build-parent-left->es db page-id)
|
||||
fix-broken-chain-tx (fix-broken-chain db' parent-left->es')]
|
||||
(when (seq fix-broken-chain-tx)
|
||||
(let [tx-data (:tx-data (d/transact! conn fix-broken-chain-tx transact-opts))]
|
||||
(let [tx-data (:tx-data (ldb/transact! conn fix-broken-chain-tx transact-opts))]
|
||||
(swap! *fix-tx-data (fn [old-data] (concat old-data tx-data)))))))
|
||||
@*fix-tx-data))
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
tx [{:file/path file-rpath}
|
||||
{:block/name (:block/name page-block)
|
||||
:block/file file}]]
|
||||
(d/transact! conn tx)
|
||||
(ldb/transact! conn tx)
|
||||
(when ok-handler (ok-handler)))))
|
||||
|
||||
(defn- remove-transit-ids [block] (dissoc block :db/id :block/file))
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
page-txs
|
||||
first-block-tx)]
|
||||
(when (seq txs)
|
||||
(d/transact! conn txs {:persist-op? persist-op?})
|
||||
(ldb/transact! conn txs {:persist-op? persist-op?})
|
||||
page-name)))))
|
||||
|
||||
(defn db-refs->page
|
||||
@@ -207,8 +207,8 @@
|
||||
db-based? (sqlite-util/db-based-graph? repo)]
|
||||
(if-let [msg (and db-based? (page-unable-to-delete conn page))]
|
||||
(do
|
||||
(d/transact! conn truncate-blocks-tx-data
|
||||
{:outliner-op :truncate-page-blocks :persist-op? persist-op?})
|
||||
(ldb/transact! conn truncate-blocks-tx-data
|
||||
{:outliner-op :truncate-page-blocks :persist-op? persist-op?})
|
||||
(error-handler msg))
|
||||
(let [file (ldb/get-page-file @conn page-name)
|
||||
file-path (:file/path file)
|
||||
@@ -230,12 +230,12 @@
|
||||
nil)
|
||||
tx-data (concat truncate-blocks-tx-data delete-page-tx delete-file-tx)]
|
||||
|
||||
(d/transact! conn tx-data
|
||||
(cond-> {:outliner-op :delete-page :persist-op? persist-op?}
|
||||
file-path
|
||||
(assoc
|
||||
:deleted-page page-name
|
||||
:file-path file-path)))
|
||||
(ldb/transact! conn tx-data
|
||||
(cond-> {:outliner-op :delete-page :persist-op? persist-op?}
|
||||
file-path
|
||||
(assoc
|
||||
:deleted-page page-name
|
||||
:file-path file-path)))
|
||||
|
||||
(when (fn? ok-handler) (ok-handler))
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
[frontend.worker.file :as file]
|
||||
[logseq.db.frontend.validate :as validate]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[frontend.worker.db.fix :as db-fix]))
|
||||
[frontend.worker.db.fix :as db-fix]
|
||||
[logseq.db :as ldb]))
|
||||
|
||||
(defn- path-refs-need-recalculated?
|
||||
[tx-meta]
|
||||
@@ -92,8 +93,8 @@
|
||||
{:db/id db-id
|
||||
:block/tx-id tx-id})) updated-blocks)
|
||||
(remove nil?))))
|
||||
tx-report' (d/transact! conn replace-tx {:replace? true
|
||||
:pipeline-replace? true})
|
||||
tx-report' (ldb/transact! conn replace-tx {:replace? true
|
||||
:pipeline-replace? true})
|
||||
full-tx-data (concat (:tx-data tx-report) fix-tx-data (:tx-data tx-report'))
|
||||
final-tx-report (assoc tx-report' :tx-data full-tx-data)
|
||||
affected-query-keys (when-not (:importing? context)
|
||||
|
||||
Reference in New Issue
Block a user