fix: wait until db transacted and then parsing the next 100 files

Related to LOG-3057
pull/11102/head
Tienson Qin 2024-03-04 16:26:18 +08:00
parent 059da6b22e
commit 49596151bb
4 changed files with 21 additions and 22 deletions

View File

@ -191,14 +191,11 @@
(doseq [k all-keys]
(when-let [cache (get state k)]
(let [{:keys [query query-fn]} cache
custom? (= :custom (first k))
{:keys [custom-query?]} (state/edit-in-query-or-refs-component)]
custom? (= :custom (first k))]
(when (or query query-fn)
(try
(let [f #(execute-query! repo-url db (vec (cons repo-url k)) cache)]
;; Detects whether user is editing in a custom query, if so, execute the query immediately
(if (and custom? (not custom-query?))
(async/put! (state/get-reactive-custom-queries-chan) [f query])
(when-not custom?
(f)))
(catch :default e
(js/console.error e)

View File

@ -156,6 +156,7 @@
{:new-graph? true
:empty-graph? (nil? (seq markup-files))
:file-objs files})
(state/set-parsing-state! {:graph-loading? false})
(state/add-repo! {:url repo :nfs? true})
(persist-db/<export-db repo {})
(state/set-loading-files! repo false)

View File

@ -21,7 +21,8 @@
[logseq.common.config :as common-config]
[clojure.core.async :as async]
[medley.core :as medley]
[logseq.common.path :as path]))
[logseq.common.path :as path]
[clojure.core.async.interop :refer [p->c]]))
(defn- create-contents-file
[repo-url]
@ -238,14 +239,15 @@
_ (when (and page-name (not page-exists?))
(swap! *page-names conj page-name)
(swap! *page-name->path assoc page-name (:file/path file)))
tx' (if (or whiteboard? (zero? (rem (inc idx) 100)))
(do (db/transact! repo-url tx' {:from-disk? true})
[])
tx' (if (zero? (rem (inc idx) 100))
(do
(async/<! (p->c (db/transact! repo-url tx' {:from-disk? true})))
[])
tx')]
(recur tx')))
(do
(when (seq tx) (db/transact! repo-url tx {:from-disk? true}))
(after-parse repo-url re-render? re-render-opts opts graph-added-chan)))))
(p/do!
(when (seq tx) (db/transact! repo-url tx {:from-disk? true}))
(after-parse repo-url re-render? re-render-opts opts graph-added-chan)))))
graph-added-chan))
(defn- parse-files-and-create-default-files!
@ -276,8 +278,7 @@
;; Load to db even it's empty, (will create default files)
(parse-files-and-load-to-db! repo-url file-objs {:new-graph? new-graph?
:empty-graph? empty-graph?})
(state/set-parsing-state! {:graph-loading? false})))
:empty-graph? empty-graph?})))
(defn load-repo-to-db!
[repo-url {:keys [diffs file-objs refresh? new-graph? empty-graph?]}]

View File

@ -31,14 +31,14 @@
file-based? (config/local-file-based-graph? repo)
_ (protocol/truncate-blocks! this)
result (.search-build-blocks-indice sqlite repo)
blocks (cond->> (bean/->clj result)
file-based?
;; remove built-in properties from content
(map #(update % :content
(fn [content]
(property-util/remove-built-in-properties (get % :format :markdown) content))))
true
bean/->js)
blocks (if file-based?
(->> (bean/->clj result)
;; remove built-in properties from content
(map #(update % :content
(fn [content]
(property-util/remove-built-in-properties (get % :format :markdown) content))))
bean/->js)
result)
_ (when (seq blocks)
(.search-upsert-blocks sqlite repo blocks))])
(p/resolved nil)))