fix: don't update local tx to 0 except for two cases

1. creating a remote graph
2. uploading a local graph
This commit is contained in:
Tienson Qin
2026-05-05 13:23:36 +08:00
parent 47407a3d8d
commit 13779a4047
4 changed files with 10 additions and 10 deletions

View File

@@ -488,7 +488,7 @@
(do
(set-creating-db? true)
(p/let [repo (repo-handler/new-db! graph-name
{:remote-graph? cloud?})]
{:creating-remote-graph? cloud?})]
(when cloud?
(->
(p/do

View File

@@ -132,13 +132,13 @@
(let [full-graph-name (string/lower-case (str config/db-version-prefix graph-name))]
(some #(= (some-> (:url %) string/lower-case) full-graph-name) (state/get-repos))))
(defn- create-db [full-graph-name {:keys [file-graph-import? remote-graph?]}]
(defn- create-db [full-graph-name {:keys [file-graph-import? creating-remote-graph?]}]
(->
(p/let [config config/config-default-content
_ (persist-db/<new full-graph-name
(cond-> {:config config
:graph-git-sha (build-version/revision)
:remote-graph? remote-graph?}
:creating-remote-graph? creating-remote-graph?}
file-graph-import? (assoc :import-type :file-graph)))
_ (start-repo-db-if-not-exists! full-graph-name)
_ (state/add-repo! {:url full-graph-name :root (config/get-local-dir full-graph-name)})

View File

@@ -408,7 +408,9 @@
:skip-validate-db? true}))))
(defn- <create-or-open-db!
[repo {:keys [config datoms sync-download-graph?] :as opts}]
[repo {:keys [config datoms sync-download-graph? creating-remote-graph?] :as opts}]
(when creating-remote-graph?
(client-op/update-local-tx repo 0))
(when-not (worker-state/get-sqlite-conn repo)
(p/let [[db search-db client-ops-db :as dbs] (get-dbs repo)
storage (new-sqlite-storage db)]
@@ -453,14 +455,12 @@
(when-not @*publishing?
(client-op/ensure-sqlite-schema! client-ops-db))
(ensure-client-ops-cleanup-timer! repo)
(when (nil? (client-op/get-local-tx repo))
(client-op/update-local-tx repo 0))
(let [initial-tx-report (when-not (or initial-data-exists?
(seq datoms)
sync-download-graph?)
(let [config (resolve-initial-config config)
initial-data (sqlite-create-graph/build-db-initial-data
config (select-keys opts [:import-type :graph-git-sha :remote-graph?]))]
config (select-keys opts [:import-type :graph-git-sha :creating-remote-graph?]))]
(ldb/transact! conn initial-data
{:initial-db? true})))]
(when-not sync-download-graph?