Skip to content

Commit 263c499

Browse files
committed
fix: ensure UI db is full when importing file graph
The long-term goal is to move all writes to the db worker.
1 parent 7dc155b commit 263c499

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/main/frontend/handler/repo.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
file-graph-import? (assoc :import-type :file-graph)))
199199
_ (start-repo-db-if-not-exists! full-graph-name)
200200
_ (state/add-repo! {:url full-graph-name :root (config/get-local-dir full-graph-name)})
201-
_ (restore-and-setup-repo! full-graph-name)
201+
_ (restore-and-setup-repo! full-graph-name {:file-graph-import? file-graph-import?})
202202
_ (when-not file-graph-import? (route-handler/redirect-to-home!))
203203
_ (repo-config-handler/set-repo-config-state! full-graph-name config/config-default-content)
204204
;; TODO: handle global graph

src/main/frontend/persist_db/browser.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
_ (when disk-db-data
220220
(state/<invoke-db-worker-direct-pass :thread-api/import-db repo disk-db-data))
221221
_ (state/<invoke-db-worker :thread-api/create-or-open-db repo opts)]
222-
(state/<invoke-db-worker :thread-api/get-initial-data repo))
222+
(state/<invoke-db-worker :thread-api/get-initial-data repo opts))
223223
(p/catch sqlite-error-handler)))
224224

225225
(<export-db [_this repo opts]

src/main/frontend/worker/db_worker.cljs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,12 @@
553553
(throw e)))))
554554

555555
(def-thread-api :thread-api/get-initial-data
556-
[repo]
556+
[repo opts]
557557
(when-let [conn (worker-state/get-datascript-conn repo)]
558-
(common-initial-data/get-initial-data @conn)))
558+
(if (:file-graph-import? opts)
559+
{:schema (:schema @conn)
560+
:initial-data (vec (d/datoms @conn :eavt))}
561+
(common-initial-data/get-initial-data @conn))))
559562

560563
(def-thread-api :thread-api/reset-db
561564
[repo db-transit]

0 commit comments

Comments
 (0)