mirror of https://github.com/logseq/logseq
chore: remove unnesessary code
parent
f2db192bb7
commit
4ce80d6957
|
@ -64,10 +64,8 @@
|
||||||
(.exportFile ^js pool path))))
|
(.exportFile ^js pool path))))
|
||||||
|
|
||||||
(defn- <import-db
|
(defn- <import-db
|
||||||
[repo data]
|
[^js pool repo data]
|
||||||
(p/let [^js pool (<get-opfs-pool repo)]
|
(.importDb ^js pool (get-repo-path repo) data))
|
||||||
(when pool
|
|
||||||
(.importDb ^js pool (get-repo-path repo) data))))
|
|
||||||
|
|
||||||
(defn upsert-addr-content!
|
(defn upsert-addr-content!
|
||||||
"Upsert addr+data-seq"
|
"Upsert addr+data-seq"
|
||||||
|
@ -105,22 +103,19 @@
|
||||||
(-restore [_ addr]
|
(-restore [_ addr]
|
||||||
(restore-data-from-addr repo addr)))))
|
(restore-data-from-addr repo addr)))))
|
||||||
|
|
||||||
|
(defn- close-db!
|
||||||
|
[repo]
|
||||||
|
(swap! *sqlite-conns dissoc repo)
|
||||||
|
(swap! *datascript-conns dissoc repo)
|
||||||
|
(swap! *opfs-pools dissoc repo))
|
||||||
|
|
||||||
(defn- close-other-dbs!
|
(defn- close-other-dbs!
|
||||||
[repo]
|
[repo]
|
||||||
(doseq [[r db] @*sqlite-conns]
|
(doseq [[r db] @*sqlite-conns]
|
||||||
(when-not (= repo r)
|
(when-not (= repo r)
|
||||||
(swap! *datascript-conns dissoc r)
|
(close-db! r)
|
||||||
(swap! *sqlite-conns dissoc r)
|
|
||||||
(swap! *opfs-pools dissoc r)
|
|
||||||
(.close ^Object db))))
|
(.close ^Object db))))
|
||||||
|
|
||||||
(defn- close-db!
|
|
||||||
[repo]
|
|
||||||
(when-let [db (@*sqlite-conns repo)]
|
|
||||||
(swap! *sqlite-conns dissoc repo)
|
|
||||||
(swap! *datascript-conns dissoc repo)
|
|
||||||
(.close ^Object db)))
|
|
||||||
|
|
||||||
(defn- create-or-open-db!
|
(defn- create-or-open-db!
|
||||||
[repo]
|
[repo]
|
||||||
(when-not (get-sqlite-conn repo)
|
(when-not (get-sqlite-conn repo)
|
||||||
|
@ -172,18 +167,11 @@
|
||||||
_ (p/all (map (fn [file] (.remove file)) files))]
|
_ (p/all (map (fn [file] (.remove file)) files))]
|
||||||
(p/all (map (fn [dir] (.remove dir)) dirs)))))
|
(p/all (map (fn [dir] (.remove dir)) dirs)))))
|
||||||
|
|
||||||
(defn- <get-pool-files
|
|
||||||
[^js pool]
|
|
||||||
(.getFileNames pool))
|
|
||||||
|
|
||||||
(defn- remove-vfs!
|
(defn- remove-vfs!
|
||||||
[repo]
|
[repo]
|
||||||
(p/let [^js pool (<get-opfs-pool repo)]
|
(p/let [^js pool (<get-opfs-pool repo)]
|
||||||
(when pool
|
(when pool
|
||||||
(p/let [files (<get-pool-files pool)
|
(.removeVfs ^js pool))))
|
||||||
_ (p/all (map (fn [file] (.unlink pool file)) files))
|
|
||||||
_ (.wipeFiles pool)]
|
|
||||||
(.removeVfs ^js pool)))))
|
|
||||||
|
|
||||||
#_:clj-kondo/ignore
|
#_:clj-kondo/ignore
|
||||||
(defclass SQLiteDB
|
(defclass SQLiteDB
|
||||||
|
@ -215,6 +203,7 @@
|
||||||
(string/replace-first (.-name file) ".logseq-pool-" "")))
|
(string/replace-first (.-name file) ".logseq-pool-" "")))
|
||||||
all-files)
|
all-files)
|
||||||
distinct)]
|
distinct)]
|
||||||
|
(prn :debug :all-files (map #(.-name %) all-files))
|
||||||
(prn :debug :all-files-count (count (filter
|
(prn :debug :all-files-count (count (filter
|
||||||
#(= (.-kind %) "file")
|
#(= (.-kind %) "file")
|
||||||
all-files)))
|
all-files)))
|
||||||
|
@ -248,10 +237,8 @@
|
||||||
|
|
||||||
(unsafeUnlinkDB
|
(unsafeUnlinkDB
|
||||||
[_this repo]
|
[_this repo]
|
||||||
(p/let [_ (close-db! repo)
|
(p/let [result (remove-vfs! repo)]
|
||||||
_ (remove-vfs! repo)]
|
(close-db! repo)))
|
||||||
(swap! *opfs-pools dissoc repo)
|
|
||||||
nil))
|
|
||||||
|
|
||||||
(exportDB
|
(exportDB
|
||||||
[_this repo]
|
[_this repo]
|
||||||
|
@ -261,7 +248,7 @@
|
||||||
[this repo data]
|
[this repo data]
|
||||||
(when-not (string/blank? repo)
|
(when-not (string/blank? repo)
|
||||||
(p/let [pool (<get-opfs-pool repo)]
|
(p/let [pool (<get-opfs-pool repo)]
|
||||||
(<import-db repo data)))))
|
(<import-db pool repo data)))))
|
||||||
|
|
||||||
(defn init
|
(defn init
|
||||||
"web worker entry"
|
"web worker entry"
|
||||||
|
|
Loading…
Reference in New Issue