|
|
@@ -30,6 +30,7 @@
|
|
|
[frontend.worker.rtc.client-op :as client-op]
|
|
|
[frontend.worker.rtc.core :as rtc.core]
|
|
|
[frontend.worker.rtc.db-listener]
|
|
|
+ [frontend.worker.rtc.encrypt :as rtc-encrypt]
|
|
|
[frontend.worker.rtc.migrate :as rtc-migrate]
|
|
|
[frontend.worker.search :as search]
|
|
|
[frontend.worker.shared-service :as shared-service]
|
|
|
@@ -260,8 +261,8 @@
|
|
|
(ldb/transact! datascript-conn [{:db/ident :logseq.kv/graph-last-gc-at
|
|
|
:kv/value (common-util/time-ms)}]))))
|
|
|
|
|
|
-(defn- create-or-open-db!
|
|
|
- [repo {:keys [config datoms] :as opts}]
|
|
|
+(defn- <create-or-open-db!
|
|
|
+ [repo {:keys [config datoms rtc-e2ee-password] :as opts}]
|
|
|
(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)
|
|
|
@@ -301,15 +302,12 @@
|
|
|
initial-data (sqlite-create-graph/build-db-initial-data
|
|
|
config (select-keys opts [:import-type :graph-git-sha]))]
|
|
|
(ldb/transact! conn initial-data {:initial-db? true})))
|
|
|
+ (let [migration-result (db-migrate/migrate conn)]
|
|
|
+ (when (client-op/rtc-db-graph? repo)
|
|
|
+ (let [client-ops (rtc-migrate/migration-results=>client-ops migration-result)]
|
|
|
+ (client-op/add-ops! repo client-ops))))
|
|
|
|
|
|
- (gc-sqlite-dbs! db client-ops-db conn {})
|
|
|
-
|
|
|
- (let [migration-result (db-migrate/migrate conn)]
|
|
|
- (when (client-op/rtc-db-graph? repo)
|
|
|
- (let [client-ops (rtc-migrate/migration-results=>client-ops migration-result)]
|
|
|
- (client-op/add-ops! repo client-ops))))
|
|
|
-
|
|
|
- (db-listener/listen-db-changes! repo (get @*datascript-conns repo))))))
|
|
|
+ (db-listener/listen-db-changes! repo (get @*datascript-conns repo)))))))
|
|
|
|
|
|
(defn- iter->vec [iter']
|
|
|
(when iter'
|
|
|
@@ -414,7 +412,7 @@
|
|
|
(when close-other-db?
|
|
|
(close-other-dbs! repo))
|
|
|
(when @shared-service/*master-client?
|
|
|
- (create-or-open-db! repo (dissoc opts :close-other-db?)))
|
|
|
+ (<create-or-open-db! repo (dissoc opts :close-other-db?)))
|
|
|
nil))
|
|
|
|
|
|
(def-thread-api :thread-api/create-or-open-db
|