mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 06:34:34 +00:00
fix: release access handles after graph has been downloaded
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
[frontend.db.rtc.op-mem-layer :as op-mem-layer]
|
||||
[frontend.db.rtc.ws :refer [<send!]]
|
||||
[frontend.persist-db :as persist-db]
|
||||
[logseq.db.frontend.schema :as db-schema]))
|
||||
[logseq.db.frontend.schema :as db-schema]
|
||||
[frontend.state :as state]))
|
||||
|
||||
(def transit-r (transit/reader :json))
|
||||
|
||||
@@ -122,9 +123,10 @@
|
||||
blocks-with-page-id (fill-block-fields blocks*)]
|
||||
(<? (p->c (persist-db/<new repo)))
|
||||
(<? (p->c (persist-db/<transact-data repo blocks-with-page-id nil)))
|
||||
(<? (p->c (persist-db/<release-access-handles repo)))
|
||||
(state/add-repo! {:url repo})
|
||||
(op-mem-layer/update-local-tx! repo t))))
|
||||
|
||||
|
||||
(defn <download-graph
|
||||
[state repo graph-uuid]
|
||||
(go-try
|
||||
|
||||
@@ -107,8 +107,12 @@
|
||||
[repo ^js db]
|
||||
(swap! *sqlite-conns dissoc repo)
|
||||
(swap! *datascript-conns dissoc repo)
|
||||
(swap! *opfs-pools dissoc repo)
|
||||
(when db (.close db)))
|
||||
|
||||
(when db (.close db))
|
||||
(when-let [^js pool (get-opfs-pool repo)]
|
||||
(.releaseAccessHandles pool))
|
||||
|
||||
(swap! *opfs-pools dissoc repo))
|
||||
|
||||
(defn- close-other-dbs!
|
||||
[repo]
|
||||
@@ -239,6 +243,11 @@
|
||||
result (remove-vfs! pool)]
|
||||
nil))
|
||||
|
||||
(releaseAccessHandles
|
||||
[_this repo]
|
||||
(when-let [^js pool (get-opfs-pool repo)]
|
||||
(.releaseAccessHandles pool)))
|
||||
|
||||
(exportDB
|
||||
[_this repo]
|
||||
(<export-db-file repo))
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
(p/let [_ (protocol/<new (get-impl) repo)]
|
||||
(<export-db repo {})))
|
||||
|
||||
(defn <release-access-handles
|
||||
[repo]
|
||||
(protocol/<release-access-handles (get-impl) repo))
|
||||
|
||||
(defn run-export-periodically!
|
||||
[]
|
||||
(js/setInterval
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
(when-let [^js sqlite @*sqlite]
|
||||
(.unsafeUnlinkDB sqlite repo)))
|
||||
|
||||
(<release-access-handles [_this repo]
|
||||
(when-let [^js sqlite @*sqlite]
|
||||
(.releaseAccessHandles sqlite repo)))
|
||||
|
||||
(<transact-data [_this repo tx-data tx-meta]
|
||||
(let [^js sqlite @*sqlite]
|
||||
(p/let [_ (when sqlite (.transact sqlite repo (pr-str tx-data) (pr-str tx-meta)))]
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
(<list-db [this] "List all databases")
|
||||
(<new [this repo] "Create or open a graph")
|
||||
(<unsafe-delete [this repo] "Delete graph and its vfs")
|
||||
(<release-access-handles [this repo] "Release access file handles")
|
||||
(<transact-data [this repo tx-data tx-meta] "Transact data to db")
|
||||
(<fetch-initial-data [this repo opts] "Fetch Initial data")
|
||||
(<export-db [this repo opts] "Save or get SQLite db")
|
||||
|
||||
Reference in New Issue
Block a user