Browse Source

Revert "fix: only look to opfs for db graphs"

This reverts commit 34a71eedaf29c282a8376ab4b35979ad0cb8c83d.
Tienson Qin 1 year ago
parent
commit
d07790af87
1 changed files with 20 additions and 1 deletions
  1. 20 1
      src/electron/electron/handler.cljs

+ 20 - 1
src/electron/electron/handler.cljs

@@ -227,6 +227,14 @@
     (fs-extra/ensureDirSync dir)
     dir))
 
+(defn- get-db-based-graphs-dir
+  []
+  (let [dir (if utils/ci?
+              (.resolve node-path js/__dirname "../tmp/graphs")
+              (.join node-path (.homedir os) "logseq" "graphs"))]
+    (fs-extra/ensureDirSync dir)
+    dir))
+
 ;; TODO: move file based graphs to "~/logseq/graphs" too
 (defn- get-file-based-graphs
   "Returns all graph names in the cache directory (starting with `logseq_local_`)"
@@ -237,9 +245,20 @@
          (map #(node-path/basename % ".transit"))
          (map graph-name->path))))
 
+(defn- get-db-based-graphs
+  "Returns all graph names in the cache directory"
+  []
+  (let [dir (get-db-based-graphs-dir)]
+    (->> (common-graph/read-directories dir)
+         (remove (fn [s] (= s db/unlinked-graphs-dir)))
+         (map graph-name->path)
+         (map (fn [s] (str sqlite-util/db-version-prefix s))))))
+
 (defn- get-graphs
   []
-  (get-file-based-graphs))
+  (concat
+   (get-file-based-graphs)
+   (get-db-based-graphs)))
 
 ;; TODO support alias mechanism
 (defn get-graph-name