mirror of https://github.com/logseq/logseq
Add fn to clean up all dbs
parent
2d0d298608
commit
aeb5026a26
|
@ -174,16 +174,6 @@
|
||||||
(swap! *datascript-conns assoc repo conn)
|
(swap! *datascript-conns assoc repo conn)
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(comment
|
|
||||||
(defn <remove-all-files!
|
|
||||||
"!! Dangerous: use it only for development."
|
|
||||||
[]
|
|
||||||
(p/let [all-files (<list-all-files)
|
|
||||||
files (filter #(= (.-kind %) "file") all-files)
|
|
||||||
dirs (filter #(= (.-kind %) "directory") all-files)
|
|
||||||
_ (p/all (map (fn [file] (.remove file)) files))]
|
|
||||||
(p/all (map (fn [dir] (.remove dir)) dirs)))))
|
|
||||||
|
|
||||||
(defn- remove-vfs!
|
(defn- remove-vfs!
|
||||||
[^js pool]
|
[^js pool]
|
||||||
(when pool
|
(when pool
|
||||||
|
@ -281,10 +271,25 @@
|
||||||
[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 pool data)))))
|
(<import-db pool data))))
|
||||||
|
|
||||||
|
(dangeriousRemoveAllDbs
|
||||||
|
[this repo]
|
||||||
|
(p/let [dbs (.listDB this)]
|
||||||
|
(p/all (map #(.unsafeUnlinkDB this %) dbs)))))
|
||||||
|
|
||||||
(defn init
|
(defn init
|
||||||
"web worker entry"
|
"web worker entry"
|
||||||
[]
|
[]
|
||||||
(let [^js obj (SQLiteDB.)]
|
(let [^js obj (SQLiteDB.)]
|
||||||
(Comlink/expose obj)))
|
(Comlink/expose obj)))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(defn <remove-all-files!
|
||||||
|
"!! Dangerous: use it only for development."
|
||||||
|
[]
|
||||||
|
(p/let [all-files (<list-all-files)
|
||||||
|
files (filter #(= (.-kind %) "file") all-files)
|
||||||
|
dirs (filter #(= (.-kind %) "directory") all-files)
|
||||||
|
_ (p/all (map (fn [file] (.remove file)) files))]
|
||||||
|
(p/all (map (fn [dir] (.remove dir)) dirs)))))
|
||||||
|
|
|
@ -114,3 +114,10 @@
|
||||||
(prn :debug :import-db-error repo)
|
(prn :debug :import-db-error repo)
|
||||||
(js/console.error error)
|
(js/console.error error)
|
||||||
(notification/show! [:div (str "SQLiteDB import error: " error)] :error) {}))))))
|
(notification/show! [:div (str "SQLiteDB import error: " error)] :error) {}))))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(defn clean-all-dbs!
|
||||||
|
[]
|
||||||
|
(when-let [sqlite @*sqlite]
|
||||||
|
(.dangeriousRemoveAllDbs sqlite)
|
||||||
|
(state/set-current-repo! nil))))
|
||||||
|
|
Loading…
Reference in New Issue