瀏覽代碼

chore: mv file-based repo and repo-config fns as well nfs

to file-based namespaces. Confirmed and QAed these are only for
file-based. This moves the majority of graph-parser/parse-file calls
into file-based namespaces. The only ones left are in handler.file which
can be done later
Gabriel Horner 1 年之前
父節點
當前提交
e0059892aa

+ 1 - 0
.clj-kondo/config.edn

@@ -89,6 +89,7 @@
              frontend.handler.file-based.page-property file-page-property
              frontend.handler.file-based.property.util property-util
              frontend.handler.file-based.recent file-recent-handler
+             frontend.handler.file-based.repo file-repo-handler
              frontend.handler.plugin plugin-handler
              frontend.handler.plugin-config plugin-config-handler
              frontend.handler.property.file property-file

+ 1 - 4
scripts/src/logseq/tasks/dev/db_and_file_graphs.clj

@@ -15,8 +15,7 @@
         ["logseq.db.sqlite." "logseq.db.frontend.property" "logseq.db.frontend.malli-schema"
          "electron.db"
          "frontend.handler.db-based."
-         "frontend.components.property" "frontend.components.class" "frontend.components.db-based"
-         "frontend.persist-db"]))
+         "frontend.components.property" "frontend.components.class" "frontend.components.db-based"]))
 
 (def file-graph-ns
   "Namespaces or parent namespaces _only_ for file graphs"
@@ -34,8 +33,6 @@
    "src/main/frontend/components/property.cljs"
    "src/main/frontend/components/property"
    "src/main/frontend/components/db_based"
-   "src/main/frontend/persist_db.cljs"
-   "src/main/frontend/persist_db"
    "src/electron/electron/db.cljs"])
 
 (def file-graph-paths

+ 2 - 2
src/main/frontend/components/file_sync.cljs

@@ -17,7 +17,7 @@
             [frontend.handler.repo :as repo-handler]
             [frontend.handler.user :as user-handler]
             [frontend.handler.page :as page-handler]
-            [frontend.handler.web.nfs :as web-nfs]
+            [frontend.handler.file-based.nfs :as nfs-handler]
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.ui :as ui]
@@ -62,7 +62,7 @@
                                  nil)
                                (.then #(do
                                          (notification/show! (str "Cloned to => " dest-dir) :success)
-                                         (web-nfs/ls-dir-files-with-path! dest-dir)
+                                         (nfs-handler/ls-dir-files-with-path! dest-dir)
                                          (repo-handler/remove-repo! {:url repo})
                                          (close-fn)))
                                (.catch #(js/console.error %)))))]

+ 1 - 1
src/main/frontend/components/header.cljs

@@ -14,7 +14,7 @@
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.route :as route-handler]
             [frontend.handler.user :as user-handler]
-            [frontend.handler.web.nfs :as nfs]
+            [frontend.handler.file-based.nfs :as nfs]
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.ui :as ui]

+ 1 - 1
src/main/frontend/components/onboarding/setups.cljs

@@ -6,7 +6,7 @@
             [frontend.components.widgets :as widgets]
             [frontend.handler.page :as page-handler]
             [frontend.util :as util]
-            [frontend.handler.web.nfs :as nfs]
+            [frontend.handler.file-based.nfs :as nfs]
             [frontend.mobile.util :as mobile-util]
             [frontend.mobile.graph-picker :as graph-picker]
             [frontend.modules.shortcut.core :as shortcut]

+ 1 - 1
src/main/frontend/components/repo.cljs

@@ -4,7 +4,7 @@
             [frontend.context.i18n :refer [t]]
             [frontend.db :as db]
             [frontend.handler.repo :as repo-handler]
-            [frontend.handler.web.nfs :as nfs-handler]
+            [frontend.handler.file-based.nfs :as nfs-handler]
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]

+ 1 - 1
src/main/frontend/components/widgets.cljs

@@ -1,7 +1,7 @@
 (ns frontend.components.widgets
   (:require [frontend.context.i18n :refer [t]]
             [frontend.handler.page :as page-handler]
-            [frontend.handler.web.nfs :as nfs]
+            [frontend.handler.file-based.nfs :as nfs]
             [frontend.modules.shortcut.core :as shortcut]
             [frontend.ui :as ui]
             [rum.core :as rum]

+ 2 - 1
src/main/frontend/handler.cljs

@@ -25,6 +25,7 @@
             [frontend.handler.page :as page-handler]
             [frontend.handler.plugin-config :as plugin-config-handler]
             [frontend.handler.repo :as repo-handler]
+            [frontend.handler.file-based.repo :as file-repo-handler]
             [frontend.handler.repo-config :as repo-config-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.handler.user :as user-handler]
@@ -94,7 +95,7 @@
                        (not (mobile-util/native-platform?))
                        (not (config/db-based-graph? repo)))
                   ;; will execute `(state/set-db-restoring! false)` inside
-                  (repo-handler/setup-demo-repo-if-not-exists!)
+                  (file-repo-handler/setup-demo-repo-if-not-exists!)
 
                   :else
                   (state/set-db-restoring! false)))))))

+ 1 - 1
src/main/frontend/handler/events.cljs

@@ -54,7 +54,7 @@
             [frontend.handler.db-based.property.util :as db-pu]
             [frontend.handler.file-based.property.util :as property-util]
             [frontend.handler.property :as property-handler]
-            [frontend.handler.web.nfs :as nfs-handler]
+            [frontend.handler.file-based.nfs :as nfs-handler]
             [frontend.handler.code :as code-handler]
             [frontend.mobile.core :as mobile]
             [frontend.mobile.graph-picker :as graph-picker]

+ 1 - 1
src/main/frontend/handler/file_based/events.cljs

@@ -5,7 +5,7 @@
             [frontend.handler.events :as events]
             [frontend.handler.page :as page-handler]
             [frontend.handler.repo :as repo-handler]
-            [frontend.handler.web.nfs :as nfs-handler]
+            [frontend.handler.file-based.nfs :as nfs-handler]
             [frontend.fs.sync :as sync]
             [frontend.state :as state]
             [frontend.ui :as ui]

+ 12 - 11
src/main/frontend/handler/web/nfs.cljs → src/main/frontend/handler/file_based/nfs.cljs

@@ -1,4 +1,4 @@
-(ns frontend.handler.web.nfs
+(ns frontend.handler.file-based.nfs
   "The File System Access API, https://web.dev/file-system-access/."
   (:require ["/frontend/utils" :as utils]
             [clojure.set :as set]
@@ -10,6 +10,7 @@
             [frontend.handler.common :as common-handler]
             [frontend.handler.global-config :as global-config-handler]
             [frontend.handler.repo :as repo-handler]
+            [frontend.handler.file-based.repo :as file-repo-handler]
             [frontend.handler.route :as route-handler]
             [frontend.idb :as idb]
             [frontend.mobile.util :as mobile-util]
@@ -151,10 +152,10 @@
                                      (repo-handler/start-repo-db-if-not-exists! repo)
                                      (when (config/global-config-enabled?)
                                        (global-config-handler/restore-global-config!))
-                                     (repo-handler/load-new-repo-to-db! repo
-                                                                        {:new-graph?   true
-                                                                         :empty-graph? (nil? (seq markup-files))
-                                                                         :file-objs    files})
+                                     (file-repo-handler/load-new-repo-to-db! repo
+                                                                             {:new-graph?   true
+                                                                              :empty-graph? (nil? (seq markup-files))
+                                                                              :file-objs    files})
                                      (state/add-repo! {:url repo :nfs? true})
                                      (persist-db/<export-db repo {})
                                      (state/set-loading-files! repo false)
@@ -241,11 +242,11 @@
                                (rename-f "modify" modified))]
                     (when (or (and (seq diffs) (seq modified-files))
                               (seq diffs))
-                      (-> (repo-handler/load-repo-to-db! repo
-                                                         {:diffs     diffs
-                                                          :nfs-files modified-files
-                                                          :refresh? (not re-index?)
-                                                          :new-graph? re-index?})
+                      (-> (file-repo-handler/load-repo-to-db! repo
+                                                              {:diffs     diffs
+                                                               :nfs-files modified-files
+                                                               :refresh? (not re-index?)
+                                                               :new-graph? re-index?})
                           (p/then (fn [_state]
                                     (ok-handler)))
                           (p/catch (fn [error]
@@ -288,7 +289,7 @@
 (defn rebuild-index!
   [repo ok-handler]
   (let [graph-dir (config/get-repo-dir repo)]
-    (when (and repo (not (config/db-based-graph? repo)))
+    (when repo
       (p/do!
        (repo-handler/remove-repo! {:url repo} :switch-graph? false)
        (ls-dir-files-with-path! graph-dir)

+ 372 - 0
src/main/frontend/handler/file_based/repo.cljs

@@ -0,0 +1,372 @@
+(ns frontend.handler.file-based.repo
+  (:require [clojure.string :as string]
+            [frontend.config :as config]
+            [frontend.context.i18n :refer [t]]
+            [frontend.date :as date]
+            [frontend.db :as db]
+            [frontend.fs :as fs]
+            [frontend.fs.nfs :as nfs]
+            [frontend.handler.file :as file-handler]
+            [frontend.handler.repo-config :as repo-config-handler]
+            [frontend.handler.common.file :as file-common-handler]
+            [frontend.handler.route :as route-handler]
+            [frontend.handler.ui :as ui-handler]
+            [frontend.spec :as spec]
+            [frontend.state :as state]
+            [frontend.util :as util]
+            [promesa.core :as p]
+            [shadow.resource :as rc]
+            [logseq.graph-parser :as graph-parser]
+            [logseq.common.config :as common-config]
+            [clojure.core.async :as async]
+            [medley.core :as medley]
+            [logseq.common.path :as path]))
+
+(defn- create-contents-file
+  [repo-url]
+  (spec/validate :repos/url repo-url)
+  (p/let [repo-dir (config/get-repo-dir repo-url)
+          pages-dir (state/get-pages-directory)
+          [org-path md-path] (map #(str pages-dir "/contents." %) ["org" "md"])
+          contents-file-exist? (some #(fs/file-exists? repo-dir %) [org-path md-path])]
+    (when-not contents-file-exist?
+      (let [format (state/get-preferred-format)
+            file-rpath (str "pages/" "contents." (config/get-file-extension format))
+            default-content (case (name format)
+                              "org" (rc/inline "templates/contents.org")
+                              "markdown" (rc/inline "templates/contents.md")
+                              "")]
+        (p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir pages-dir))
+                file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath default-content)]
+          (when-not file-exists?
+            (file-common-handler/reset-file! repo-url file-rpath default-content)))))))
+
+(defn- create-custom-theme
+  [repo-url]
+  (spec/validate :repos/url repo-url)
+  (let [repo-dir (config/get-repo-dir repo-url)
+        path (str config/app-name "/" config/custom-css-file)
+        file-rpath path
+        default-content ""]
+    (p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name))
+            file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath default-content)]
+      (when-not file-exists?
+        (file-common-handler/reset-file! repo-url path default-content)))))
+
+(defn- create-dummy-notes-page
+  [repo-url content]
+  (spec/validate :repos/url repo-url)
+  (let [repo-dir (config/get-repo-dir repo-url)
+        file-rpath (str (config/get-pages-directory) "/how_to_make_dummy_notes.md")]
+    (p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-pages-directory)))
+            _file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath content)]
+      (file-common-handler/reset-file! repo-url file-rpath content))))
+
+(defn- create-today-journal-if-not-exists
+  [repo-url {:keys [content]}]
+  (spec/validate :repos/url repo-url)
+  (when (state/enable-journals? repo-url)
+    (let [repo-dir (config/get-repo-dir repo-url)
+          format (state/get-preferred-format repo-url)
+          title (date/today)
+          file-name (date/journal-title->default title)
+          default-content (util/default-content-with-title format)
+          template (state/get-default-journal-template)
+          template (when (and template
+                              (not (string/blank? template)))
+                     template)
+          content (cond
+                    content
+                    content
+
+                    template
+                    (str default-content template)
+
+                    :else
+                    default-content)
+          file-rpath (path/path-join (config/get-journals-directory) (str file-name "."
+                                                                          (config/get-file-extension format)))
+          page-exists? (db/entity repo-url [:block/name (util/page-name-sanity-lc title)])
+          empty-blocks? (db/page-empty? repo-url (util/page-name-sanity-lc title))]
+      (when (or empty-blocks? (not page-exists?))
+        (p/let [_ (nfs/check-directory-permission! repo-url)
+                _ (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-journals-directory)))
+                file-exists? (fs/file-exists? repo-dir file-rpath)]
+          (when-not file-exists?
+            (p/let [_ (file-common-handler/reset-file! repo-url file-rpath content)]
+              (fs/create-if-not-exists repo-url repo-dir file-rpath content))))))))
+
+
+(defn create-config-file-if-not-exists
+  "Creates a default logseq/config.edn if it doesn't exist"
+  [repo-url]
+  (spec/validate :repos/url repo-url)
+  (let [repo-dir (config/get-repo-dir repo-url)
+        app-dir config/app-name
+        dir (path/path-join repo-dir app-dir)]
+    (p/let [_ (fs/mkdir-if-not-exists dir)]
+      (let [default-content config/config-default-content
+            path (str app-dir "/" config/config-file)]
+        (p/let [file-exists? (fs/create-if-not-exists repo-url repo-dir "logseq/config.edn" default-content)]
+          (when-not file-exists?
+            (file-common-handler/reset-file! repo-url path default-content)
+            (repo-config-handler/set-repo-config-state! repo-url default-content)))))))
+
+(defn- create-default-files!
+  [repo-url]
+  (spec/validate :repos/url repo-url)
+  (let [repo-dir (config/get-repo-dir repo-url)]
+    (p/do! (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name))
+           (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name config/recycle-dir))
+           (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-journals-directory)))
+           (create-config-file-if-not-exists repo-url)
+           (create-contents-file repo-url)
+           (create-custom-theme repo-url)
+           (state/pub-event! [:page/create-today-journal repo-url]))))
+
+(defonce *file-tx (atom nil))
+
+(defn- parse-and-load-file!
+  "Accept: .md, .org, .edn, .css"
+  [repo-url file {:keys [new-graph? verbose skip-db-transact? extracted-block-ids]
+                  :or {skip-db-transact? true}}]
+  (try
+    (reset! *file-tx
+            (file-handler/alter-file repo-url
+                                     (:file/path file)
+                                     (:file/content file)
+                                     (merge {:new-graph? new-graph?
+                                             :re-render-root? false
+                                             :from-disk? true
+                                             :skip-db-transact? skip-db-transact?}
+                                            ;; To avoid skipping the `:or` bounds for keyword destructuring
+                                            (when (some? extracted-block-ids) {:extracted-block-ids extracted-block-ids})
+                                            (when (some? verbose) {:verbose verbose}))))
+    (state/set-parsing-state! (fn [m]
+                                (update m :finished inc)))
+    @*file-tx
+    (catch :default e
+      (println "Parse and load file failed: " (str (:file/path file)))
+      (js/console.error e)
+      (state/set-parsing-state! (fn [m]
+                                  (update m :failed-parsing-files conj [(:file/path file) e])))
+      (state/set-parsing-state! (fn [m]
+                                  (update m :finished inc)))
+      nil)))
+
+(defn- after-parse
+  [repo-url re-render? re-render-opts opts graph-added-chan]
+  (when (or (:new-graph? opts) (not (:refresh? opts)))
+    (create-default-files! repo-url))
+  (when re-render?
+    (ui-handler/re-render-root! re-render-opts))
+  (state/pub-event! [:graph/added repo-url opts])
+  (let [parse-errors (get-in @state/state [:graph/parsing-state repo-url :failed-parsing-files])]
+    (when (seq parse-errors)
+      (state/pub-event! [:file/parse-and-load-error repo-url parse-errors])))
+  (state/reset-parsing-state!)
+  (state/set-loading-files! repo-url false)
+  (async/offer! graph-added-chan true))
+
+(defn- parse-files-and-create-default-files-inner!
+  [repo-url files delete-files delete-blocks re-render? re-render-opts opts]
+  (let [supported-files (graph-parser/filter-files files)
+        delete-data (->> (concat delete-files delete-blocks)
+                         (remove nil?))
+        indexed-files (medley/indexed supported-files)
+        chan (async/to-chan! indexed-files)
+        graph-added-chan (async/promise-chan)
+        total (count supported-files)
+        large-graph? (> total 1000)
+        *page-names (atom #{})
+        *page-name->path (atom {})
+        *extracted-block-ids (atom #{})]
+    (when (seq delete-data) (db/transact! repo-url delete-data {:delete-files? true}))
+    (state/set-current-repo! repo-url)
+    (state/set-parsing-state! {:total (count supported-files)})
+    ;; Synchronous for tests for not breaking anything
+    (if util/node-test?
+      (do
+        (doseq [file supported-files]
+          (state/set-parsing-state! (fn [m]
+                                      (assoc m
+                                             :current-parsing-file (:file/path file))))
+          (parse-and-load-file! repo-url file (assoc
+                                               (select-keys opts [:new-graph? :verbose])
+                                               :skip-db-transact? false)))
+        (after-parse repo-url re-render? re-render-opts opts graph-added-chan))
+      (async/go-loop [tx []]
+        (if-let [item (async/<! chan)]
+          (let [[idx file] item
+                whiteboard? (common-config/whiteboard? (:file/path file))
+                yield-for-ui? (or (not large-graph?)
+                                  (zero? (rem idx 10))
+                                  (<= (- total idx) 10)
+                                  whiteboard?)]
+            (state/set-parsing-state! (fn [m]
+                                        (assoc m :current-parsing-file (:file/path file))))
+
+            (when yield-for-ui? (async/<! (async/timeout 1)))
+
+            (let [opts' (-> (select-keys opts [:new-graph? :verbose])
+                            (assoc :extracted-block-ids *extracted-block-ids))
+                  ;; whiteboards might have conflicting block IDs so that db transaction could be failed
+                  opts' (if whiteboard?
+                          (assoc opts' :skip-db-transact? false)
+                          opts')
+                  result (parse-and-load-file! repo-url file opts')
+                  page-name (when (coll? result) ; result could be a promise
+                              (some (fn [x] (when (and (map? x)
+                                                       (:block/original-name x)
+                                                       (= (:file/path file) (:file/path (:block/file x))))
+                                              (:block/name x)))
+                                    result))
+                  page-exists? (and page-name (get @*page-names page-name))
+                  tx' (cond
+                        whiteboard? tx
+                        page-exists? (do
+                                       (state/pub-event! [:notification/show
+                                                          {:content [:div
+                                                                     (util/format "The file \"%s\" will be skipped because another file \"%s\" has the same page title."
+                                                                                  (:file/path file)
+                                                                                  (get @*page-name->path page-name))]
+                                                           :status :warning
+                                                           :clear? false}])
+                                       tx)
+                        :else (concat tx result))
+                  _ (when (and page-name (not page-exists?))
+                      (swap! *page-names conj page-name)
+                      (swap! *page-name->path assoc page-name (:file/path file)))
+                  tx' (if (or whiteboard? (zero? (rem (inc idx) 100)))
+                        (do (db/transact! repo-url tx' {:from-disk? true})
+                            [])
+                        tx')]
+              (recur tx')))
+          (do
+            (when (seq tx) (db/transact! repo-url tx {:from-disk? true}))
+            (after-parse repo-url re-render? re-render-opts opts graph-added-chan)))))
+    graph-added-chan))
+
+(defn- parse-files-and-create-default-files!
+  [repo-url files delete-files delete-blocks re-render? re-render-opts opts]
+  (parse-files-and-create-default-files-inner! repo-url files delete-files delete-blocks re-render? re-render-opts opts))
+
+(defn parse-files-and-load-to-db!
+  [repo-url files {:keys [delete-files delete-blocks re-render? re-render-opts _refresh?] :as opts
+                   :or {re-render? true}}]
+  (parse-files-and-create-default-files! repo-url files delete-files delete-blocks re-render? re-render-opts opts))
+
+(defn load-new-repo-to-db!
+  "load graph files to db."
+  [repo-url {:keys [file-objs new-graph? empty-graph?]}]
+  (spec/validate :repos/url repo-url)
+  (route-handler/redirect-to-home!)
+  (prn ::load-new-repo repo-url :empty-graph? empty-graph? :new-graph? new-graph?)
+  (state/set-parsing-state! {:graph-loading? true})
+  (let [config (or (when-let [content (some-> (first (filter #(= "logseq/config.edn" (:file/path %)) file-objs))
+                                              :file/content)]
+                     (repo-config-handler/read-repo-config content))
+                   (state/get-config repo-url))
+        ;; NOTE: Use config while parsing. Make sure it's the current journal title format
+        ;; config should be loaded to state first
+        _ (state/set-config! repo-url config)
+        ;; remove :hidden files from file-objs, :hidden
+        file-objs (common-config/remove-hidden-files file-objs config :file/path)]
+
+    ;; Load to db even it's empty, (will create default files)
+    (parse-files-and-load-to-db! repo-url file-objs {:new-graph? new-graph?
+                                                     :empty-graph? empty-graph?})
+    (state/set-parsing-state! {:graph-loading? false})))
+
+
+
+(defn load-repo-to-db!
+  [repo-url {:keys [diffs file-objs refresh? new-graph? empty-graph?]}]
+  (spec/validate :repos/url repo-url)
+  (route-handler/redirect-to-home!)
+  (prn ::load-repo-to-db! repo-url)
+  (state/set-parsing-state! {:graph-loading? true})
+  (let [config (or (when-let [content (some-> (first (filter #(= (config/get-repo-config-path) (:file/path %)) file-objs))
+                                              :file/content)]
+                     (repo-config-handler/read-repo-config content))
+                   (state/get-config repo-url))
+        ;; NOTE: Use config while parsing. Make sure it's the current journal title format
+        _ (state/set-config! repo-url config)
+        nfs-files (common-config/remove-hidden-files file-objs config :file/node-node-path)
+        diffs (common-config/remove-hidden-files diffs config :path)
+        load-contents (fn [files option]
+                        (file-handler/load-files-contents!
+                         repo-url
+                         files
+                         (fn [files-contents]
+                           (parse-files-and-load-to-db! repo-url files-contents (assoc option :refresh? refresh?)))))]
+    (cond
+      (and (not (seq diffs)) nfs-files)
+      (parse-files-and-load-to-db! repo-url nfs-files {:new-graph? new-graph?
+                                                       :empty-graph? empty-graph?})
+
+      :else
+      (when (seq diffs)
+        (let [filter-diffs (fn [type] (->> (filter (fn [f] (= type (:type f))) diffs)
+                                           (map :path)))
+              remove-files (filter-diffs "remove")
+              modify-files (filter-diffs "modify")
+              add-files (filter-diffs "add")
+              delete-files (when (seq remove-files)
+                             (db/delete-files remove-files))
+              delete-blocks (db/delete-blocks repo-url remove-files true)
+              delete-blocks (->>
+                             (concat
+                              delete-blocks
+                              (db/delete-blocks repo-url modify-files false))
+                             (remove nil?))
+              delete-pages (if (seq remove-files)
+                             (db/delete-pages-by-files remove-files)
+                             [])
+              add-or-modify-files (some->>
+                                   (concat modify-files add-files)
+                                   (remove nil?))
+              options {:delete-files (concat delete-files delete-pages)
+                       :delete-blocks delete-blocks
+                       :re-render? true}]
+          (if (seq nfs-files)
+            (parse-files-and-load-to-db! repo-url nfs-files
+                                         (assoc options
+                                                :refresh? refresh?
+                                                :re-render-opts {:clear-all-query-state? true}))
+            (load-contents add-or-modify-files options)))))))
+
+(defn- setup-demo-repo-if-not-exists-impl!
+  []
+  ;; loop query if js/window.pfs is ready, interval 100ms
+  (if js/window.pfs
+    (let [repo config/demo-repo
+          repo-dir (config/get-repo-dir repo)]
+      (p/do! (fs/mkdir-if-not-exists repo-dir) ;; create memory://local
+             (state/set-current-repo! repo)
+             (db/start-db-conn! repo {})
+             (when-not config/publishing?
+               (let [dummy-notes (t :tutorial/dummy-notes)]
+                 (create-dummy-notes-page repo dummy-notes)))
+             (when-not config/publishing?
+               (let [tutorial (t :tutorial/text)
+                     tutorial (string/replace-first tutorial "$today" (date/today))]
+                 (create-today-journal-if-not-exists repo {:content tutorial})))
+             (create-config-file-if-not-exists repo)
+             (create-contents-file repo)
+             (create-custom-theme repo)
+             (state/set-db-restoring! false)
+             (ui-handler/re-render-root!)))
+    (p/then (p/delay 100) ;; TODO Junyi remove the string
+            setup-demo-repo-if-not-exists-impl!)))
+
+(defn setup-demo-repo-if-not-exists!
+  "Setup demo repo, i.e. `demo-repo`"
+  []
+  ;; ensure `(state/set-db-restoring! false)` at exit
+  (-> (setup-demo-repo-if-not-exists-impl!)
+      (p/timeout 3000)
+      (p/catch (fn []
+                 (prn "setup-demo-repo failed! timeout 3000ms")))
+      (p/finally (fn []
+                   (state/set-db-restoring! false)))))

+ 2 - 1
src/main/frontend/handler/import.cljs

@@ -5,6 +5,7 @@
             [frontend.external :as external]
             [frontend.handler.file :as file-handler]
             [frontend.handler.repo :as repo-handler]
+            [frontend.handler.file-based.repo :as file-repo-handler]
             [frontend.state :as state]
             [frontend.date :as date]
             [frontend.config :as config]
@@ -51,7 +52,7 @@
                             :file/content text}))))
                 files)
         files (remove nil? files)]
-    (repo-handler/parse-files-and-load-to-db! repo files nil)
+    (file-repo-handler/parse-files-and-load-to-db! repo files nil)
     (let [files (->> (map (fn [{:file/keys [path content]}] (when path [path content])) files)
                      (remove nil?))]
       (file-handler/alter-files repo files {:add-history? false

+ 2 - 2
src/main/frontend/handler/page.cljs

@@ -16,7 +16,7 @@
             [frontend.handler.notification :as notification]
             [frontend.handler.property :as property-handler]
             [frontend.handler.ui :as ui-handler]
-            [frontend.handler.web.nfs :as web-nfs]
+            [frontend.handler.file-based.nfs :as nfs-handler]
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.util :as util]
@@ -219,7 +219,7 @@
 (defn ls-dir-files!
   ([ok-handler] (ls-dir-files! ok-handler nil))
   ([ok-handler opts]
-   (web-nfs/ls-dir-files-with-handler!
+   (nfs-handler/ls-dir-files-with-handler!
     (fn [e]
       (init-commands!)
       (when ok-handler

+ 0 - 346
src/main/frontend/handler/repo.cljs

@@ -3,345 +3,34 @@
   (:refer-clojure :exclude [clone])
   (:require [clojure.string :as string]
             [frontend.config :as config]
-            [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.db.restore :as db-restore]
-            [frontend.fs :as fs]
-            [frontend.fs.nfs :as nfs]
-            [frontend.handler.file :as file-handler]
             [frontend.handler.repo-config :as repo-config-handler]
             [frontend.handler.common.config-edn :as config-edn-common-handler]
-            [frontend.handler.common.file :as file-common-handler]
             [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.handler.notification :as notification]
             [frontend.handler.global-config :as global-config-handler]
             [frontend.idb :as idb]
             [frontend.search :as search]
-            [frontend.spec :as spec]
             [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.fs :as util-fs]
             [frontend.util.text :as text-util]
             [frontend.persist-db :as persist-db]
             [promesa.core :as p]
-            [shadow.resource :as rc]
             [frontend.db.persist :as db-persist]
-            [logseq.graph-parser :as graph-parser]
-            [logseq.common.config :as common-config]
             [logseq.db.sqlite.create-graph :as sqlite-create-graph]
             [electron.ipc :as ipc]
             [cljs-bean.core :as bean]
-            [clojure.core.async :as async]
             [frontend.mobile.util :as mobile-util]
-            [medley.core :as medley]
-            [logseq.common.path :as path]
             [borkdude.rewrite-edn :as rewrite]))
 
 ;; Project settings should be checked in two situations:
 ;; 1. User changes the config.edn directly in logseq.com (fn: alter-file)
 ;; 2. Git pulls the new change (fn: load-files)
 
-(defn create-contents-file
-  [repo-url]
-  (spec/validate :repos/url repo-url)
-  (p/let [repo-dir (config/get-repo-dir repo-url)
-          pages-dir (state/get-pages-directory)
-          [org-path md-path] (map #(str pages-dir "/contents." %) ["org" "md"])
-          contents-file-exist? (some #(fs/file-exists? repo-dir %) [org-path md-path])]
-    (when-not contents-file-exist?
-      (let [format (state/get-preferred-format)
-            file-rpath (str "pages/" "contents." (config/get-file-extension format))
-            default-content (case (name format)
-                              "org" (rc/inline "templates/contents.org")
-                              "markdown" (rc/inline "templates/contents.md")
-                              "")]
-        (p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir pages-dir))
-                file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath default-content)]
-          (when-not file-exists?
-            (file-common-handler/reset-file! repo-url file-rpath default-content)))))))
-
-(defn create-custom-theme
-  [repo-url]
-  (spec/validate :repos/url repo-url)
-  (let [repo-dir (config/get-repo-dir repo-url)
-        path (str config/app-name "/" config/custom-css-file)
-        file-rpath path
-        default-content ""]
-    (p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name))
-            file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath default-content)]
-      (when-not file-exists?
-        (file-common-handler/reset-file! repo-url path default-content)))))
-
-(defn create-dummy-notes-page
-  [repo-url content]
-  (spec/validate :repos/url repo-url)
-  (let [repo-dir (config/get-repo-dir repo-url)
-        file-rpath (str (config/get-pages-directory) "/how_to_make_dummy_notes.md")]
-    (p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-pages-directory)))
-            _file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath content)]
-      (file-common-handler/reset-file! repo-url file-rpath content))))
-
-(defn- create-today-journal-if-not-exists
-  [repo-url {:keys [content]}]
-  (spec/validate :repos/url repo-url)
-  (when (state/enable-journals? repo-url)
-    (let [repo-dir (config/get-repo-dir repo-url)
-          format (state/get-preferred-format repo-url)
-          title (date/today)
-          file-name (date/journal-title->default title)
-          default-content (util/default-content-with-title format)
-          template (state/get-default-journal-template)
-          template (when (and template
-                              (not (string/blank? template)))
-                     template)
-          content (cond
-                    content
-                    content
-
-                    template
-                    (str default-content template)
-
-                    :else
-                    default-content)
-          file-rpath (path/path-join (config/get-journals-directory) (str file-name "."
-                                                                          (config/get-file-extension format)))
-          page-exists? (db/entity repo-url [:block/name (util/page-name-sanity-lc title)])
-          empty-blocks? (db/page-empty? repo-url (util/page-name-sanity-lc title))]
-      (when (or empty-blocks? (not page-exists?))
-        (p/let [_ (nfs/check-directory-permission! repo-url)
-                _ (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-journals-directory)))
-                file-exists? (fs/file-exists? repo-dir file-rpath)]
-          (when-not file-exists?
-            (p/let [_ (file-common-handler/reset-file! repo-url file-rpath content)]
-              (fs/create-if-not-exists repo-url repo-dir file-rpath content))))))))
-
-(defn create-default-files!
-  [repo-url]
-  (spec/validate :repos/url repo-url)
-  (let [repo-dir (config/get-repo-dir repo-url)]
-    (p/do! (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name))
-           (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name config/recycle-dir))
-           (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-journals-directory)))
-           (repo-config-handler/create-config-file-if-not-exists repo-url)
-           (create-contents-file repo-url)
-           (create-custom-theme repo-url)
-           (state/pub-event! [:page/create-today-journal repo-url]))))
-
-(defonce *file-tx (atom nil))
-
-(defn- parse-and-load-file!
-  "Accept: .md, .org, .edn, .css"
-  [repo-url file {:keys [new-graph? verbose skip-db-transact? extracted-block-ids]
-                  :or {skip-db-transact? true}}]
-  (try
-    (reset! *file-tx
-            (file-handler/alter-file repo-url
-                                     (:file/path file)
-                                     (:file/content file)
-                                     (merge {:new-graph? new-graph?
-                                             :re-render-root? false
-                                             :from-disk? true
-                                             :skip-db-transact? skip-db-transact?}
-                                            ;; To avoid skipping the `:or` bounds for keyword destructuring
-                                            (when (some? extracted-block-ids) {:extracted-block-ids extracted-block-ids})
-                                            (when (some? verbose) {:verbose verbose}))))
-    (state/set-parsing-state! (fn [m]
-                                (update m :finished inc)))
-    @*file-tx
-    (catch :default e
-      (println "Parse and load file failed: " (str (:file/path file)))
-      (js/console.error e)
-      (state/set-parsing-state! (fn [m]
-                                  (update m :failed-parsing-files conj [(:file/path file) e])))
-      (state/set-parsing-state! (fn [m]
-                                  (update m :finished inc)))
-      nil)))
-
-(defn- after-parse
-  [repo-url re-render? re-render-opts opts graph-added-chan]
-  (when (or (:new-graph? opts) (not (:refresh? opts)))
-    (create-default-files! repo-url))
-  (when re-render?
-    (ui-handler/re-render-root! re-render-opts))
-  (state/pub-event! [:graph/added repo-url opts])
-  (let [parse-errors (get-in @state/state [:graph/parsing-state repo-url :failed-parsing-files])]
-    (when (seq parse-errors)
-      (state/pub-event! [:file/parse-and-load-error repo-url parse-errors])))
-  (state/reset-parsing-state!)
-  (state/set-loading-files! repo-url false)
-  (async/offer! graph-added-chan true))
-
-(defn- parse-files-and-create-default-files-inner!
-  [repo-url files delete-files delete-blocks re-render? re-render-opts opts]
-  (let [supported-files (graph-parser/filter-files files)
-        delete-data (->> (concat delete-files delete-blocks)
-                         (remove nil?))
-        indexed-files (medley/indexed supported-files)
-        chan (async/to-chan! indexed-files)
-        graph-added-chan (async/promise-chan)
-        total (count supported-files)
-        large-graph? (> total 1000)
-        *page-names (atom #{})
-        *page-name->path (atom {})
-        *extracted-block-ids (atom #{})]
-    (when (seq delete-data) (db/transact! repo-url delete-data {:delete-files? true}))
-    (state/set-current-repo! repo-url)
-    (state/set-parsing-state! {:total (count supported-files)})
-    ;; Synchronous for tests for not breaking anything
-    (if util/node-test?
-      (do
-        (doseq [file supported-files]
-          (state/set-parsing-state! (fn [m]
-                                      (assoc m
-                                             :current-parsing-file (:file/path file))))
-          (parse-and-load-file! repo-url file (assoc
-                                               (select-keys opts [:new-graph? :verbose])
-                                               :skip-db-transact? false)))
-        (after-parse repo-url re-render? re-render-opts opts graph-added-chan))
-      (async/go-loop [tx []]
-        (if-let [item (async/<! chan)]
-          (let [[idx file] item
-                whiteboard? (common-config/whiteboard? (:file/path file))
-                yield-for-ui? (or (not large-graph?)
-                                  (zero? (rem idx 10))
-                                  (<= (- total idx) 10)
-                                  whiteboard?)]
-            (state/set-parsing-state! (fn [m]
-                                        (assoc m :current-parsing-file (:file/path file))))
-
-            (when yield-for-ui? (async/<! (async/timeout 1)))
-
-            (let [opts' (-> (select-keys opts [:new-graph? :verbose])
-                            (assoc :extracted-block-ids *extracted-block-ids))
-                  ;; whiteboards might have conflicting block IDs so that db transaction could be failed
-                  opts' (if whiteboard?
-                          (assoc opts' :skip-db-transact? false)
-                          opts')
-                  result (parse-and-load-file! repo-url file opts')
-                  page-name (when (coll? result) ; result could be a promise
-                              (some (fn [x] (when (and (map? x)
-                                                       (:block/original-name x)
-                                                       (= (:file/path file) (:file/path (:block/file x))))
-                                              (:block/name x)))
-                                    result))
-                  page-exists? (and page-name (get @*page-names page-name))
-                  tx' (cond
-                        whiteboard? tx
-                        page-exists? (do
-                                       (state/pub-event! [:notification/show
-                                                          {:content [:div
-                                                                     (util/format "The file \"%s\" will be skipped because another file \"%s\" has the same page title."
-                                                                                  (:file/path file)
-                                                                                  (get @*page-name->path page-name))]
-                                                           :status :warning
-                                                           :clear? false}])
-                                       tx)
-                        :else (concat tx result))
-                  _ (when (and page-name (not page-exists?))
-                      (swap! *page-names conj page-name)
-                      (swap! *page-name->path assoc page-name (:file/path file)))
-                  tx' (if (or whiteboard? (zero? (rem (inc idx) 100)))
-                        (do (db/transact! repo-url tx' {:from-disk? true})
-                            [])
-                        tx')]
-              (recur tx')))
-          (do
-            (when (seq tx) (db/transact! repo-url tx {:from-disk? true}))
-            (after-parse repo-url re-render? re-render-opts opts graph-added-chan)))))
-    graph-added-chan))
-
-(defn- parse-files-and-create-default-files!
-  [repo-url files delete-files delete-blocks re-render? re-render-opts opts]
-  (parse-files-and-create-default-files-inner! repo-url files delete-files delete-blocks re-render? re-render-opts opts))
-
-(defn parse-files-and-load-to-db!
-  [repo-url files {:keys [delete-files delete-blocks re-render? re-render-opts _refresh?] :as opts
-                   :or {re-render? true}}]
-  (parse-files-and-create-default-files! repo-url files delete-files delete-blocks re-render? re-render-opts opts))
-
-
-
-(defn load-new-repo-to-db!
-  "load graph files to db."
-  [repo-url {:keys [file-objs new-graph? empty-graph?]}]
-  (spec/validate :repos/url repo-url)
-  (route-handler/redirect-to-home!)
-  (prn ::load-new-repo repo-url :empty-graph? empty-graph? :new-graph? new-graph?)
-  (state/set-parsing-state! {:graph-loading? true})
-  (let [config (or (when-let [content (some-> (first (filter #(= "logseq/config.edn" (:file/path %)) file-objs))
-                                              :file/content)]
-                     (repo-config-handler/read-repo-config content))
-                   (state/get-config repo-url))
-        ;; NOTE: Use config while parsing. Make sure it's the current journal title format
-        ;; config should be loaded to state first
-        _ (state/set-config! repo-url config)
-        ;; remove :hidden files from file-objs, :hidden
-        file-objs (common-config/remove-hidden-files file-objs config :file/path)]
-
-    ;; Load to db even it's empty, (will create default files)
-    (parse-files-and-load-to-db! repo-url file-objs {:new-graph? new-graph?
-                                                     :empty-graph? empty-graph?})
-    (state/set-parsing-state! {:graph-loading? false})))
-
-
-
-(defn load-repo-to-db!
-  [repo-url {:keys [diffs file-objs refresh? new-graph? empty-graph?]}]
-  (spec/validate :repos/url repo-url)
-  (route-handler/redirect-to-home!)
-  (state/set-parsing-state! {:graph-loading? true})
-  (let [config (or (when-let [content (some-> (first (filter #(= (config/get-repo-config-path) (:file/path %)) file-objs))
-                                              :file/content)]
-                     (repo-config-handler/read-repo-config content))
-                   (state/get-config repo-url))
-        ;; NOTE: Use config while parsing. Make sure it's the current journal title format
-        _ (state/set-config! repo-url config)
-        nfs-files (common-config/remove-hidden-files file-objs config :file/node-node-path)
-        diffs (common-config/remove-hidden-files diffs config :path)
-        load-contents (fn [files option]
-                        (file-handler/load-files-contents!
-                         repo-url
-                         files
-                         (fn [files-contents]
-                           (parse-files-and-load-to-db! repo-url files-contents (assoc option :refresh? refresh?)))))]
-    (cond
-      (and (not (seq diffs)) nfs-files)
-      (parse-files-and-load-to-db! repo-url nfs-files {:new-graph? new-graph?
-                                                       :empty-graph? empty-graph?})
-
-      :else
-      (when (seq diffs)
-        (let [filter-diffs (fn [type] (->> (filter (fn [f] (= type (:type f))) diffs)
-                                           (map :path)))
-              remove-files (filter-diffs "remove")
-              modify-files (filter-diffs "modify")
-              add-files (filter-diffs "add")
-              delete-files (when (seq remove-files)
-                             (db/delete-files remove-files))
-              delete-blocks (db/delete-blocks repo-url remove-files true)
-              delete-blocks (->>
-                             (concat
-                              delete-blocks
-                              (db/delete-blocks repo-url modify-files false))
-                             (remove nil?))
-              delete-pages (if (seq remove-files)
-                             (db/delete-pages-by-files remove-files)
-                             [])
-              add-or-modify-files (some->>
-                                   (concat modify-files add-files)
-                                   (remove nil?))
-              options {:delete-files (concat delete-files delete-pages)
-                       :delete-blocks delete-blocks
-                       :re-render? true}]
-          (if (seq nfs-files)
-            (parse-files-and-load-to-db! repo-url nfs-files
-                                         (assoc options
-                                                :refresh? refresh?
-                                                :re-render-opts {:clear-all-query-state? true}))
-            (load-contents add-or-modify-files options)))))))
-
 (defn remove-repo!
   [{:keys [url] :as repo} & {:keys [switch-graph?]
                              :or {switch-graph? true}}]
@@ -372,41 +61,6 @@
                            opts
                            {:db-graph? (config/db-based-graph? repo)})))
 
-(defn- setup-demo-repo-if-not-exists-impl!
-  []
-  ;; loop query if js/window.pfs is ready, interval 100ms
-  (if js/window.pfs
-    (let [repo config/demo-repo
-          repo-dir (config/get-repo-dir repo)]
-      (p/do! (fs/mkdir-if-not-exists repo-dir) ;; create memory://local
-             (state/set-current-repo! repo)
-             (db/start-db-conn! repo {})
-             (when-not config/publishing?
-               (let [dummy-notes (t :tutorial/dummy-notes)]
-                 (create-dummy-notes-page repo dummy-notes)))
-             (when-not config/publishing?
-               (let [tutorial (t :tutorial/text)
-                     tutorial (string/replace-first tutorial "$today" (date/today))]
-                 (create-today-journal-if-not-exists repo {:content tutorial})))
-             (repo-config-handler/create-config-file-if-not-exists repo)
-             (create-contents-file repo)
-             (create-custom-theme repo)
-             (state/set-db-restoring! false)
-             (ui-handler/re-render-root!)))
-    (p/then (p/delay 100) ;; TODO Junyi remove the string
-            setup-demo-repo-if-not-exists-impl!)))
-
-(defn setup-demo-repo-if-not-exists!
-  "Setup demo repo, i.e. `demo-repo`"
-  []
-  ;; ensure `(state/set-db-restoring! false)` at exit
-  (-> (setup-demo-repo-if-not-exists-impl!)
-      (p/timeout 3000)
-      (p/catch (fn []
-                 (prn "setup-demo-repo failed! timeout 3000ms")))
-      (p/finally (fn []
-                   (state/set-db-restoring! false)))))
-
 (defn restore-and-setup-repo!
   "Restore the db of a graph from the persisted data, and setup. Create a new
   conn, or replace the conn in state with a new one."

+ 1 - 22
src/main/frontend/handler/repo_config.cljs

@@ -4,15 +4,9 @@
   logseq/config.edn. In the future it may manage more files. This component
   depends on a repo."
   (:require [clojure.edn :as edn]
-            [frontend.config :as config]
             [frontend.db :as db]
-            [frontend.fs :as fs]
-            [logseq.common.path :as path]
-            [frontend.handler.common.file :as file-common-handler]
             [frontend.handler.notification :as notification]
-            [frontend.spec :as spec]
-            [frontend.state :as state]
-            [promesa.core :as p]))
+            [frontend.state :as state]))
 
 (defn- get-repo-config-content
   [repo-url]
@@ -35,21 +29,6 @@
     (state/set-config! repo-url config)
     config))
 
-(defn create-config-file-if-not-exists
-  "Creates a default logseq/config.edn if it doesn't exist"
-  [repo-url]
-  (spec/validate :repos/url repo-url)
-  (let [repo-dir (config/get-repo-dir repo-url)
-        app-dir config/app-name
-        dir (path/path-join repo-dir app-dir)]
-    (p/let [_ (fs/mkdir-if-not-exists dir)]
-      (let [default-content config/config-default-content
-            path (str app-dir "/" config/config-file)]
-        (p/let [file-exists? (fs/create-if-not-exists repo-url repo-dir "logseq/config.edn" default-content)]
-          (when-not file-exists?
-            (file-common-handler/reset-file! repo-url path default-content)
-            (set-repo-config-state! repo-url default-content)))))))
-
 (defn restore-repo-config!
   "Sets repo config state from db"
   ([repo-url]

+ 2 - 2
src/main/frontend/mobile/graph_picker.cljs

@@ -4,7 +4,7 @@
    [rum.core :as rum]
    [frontend.ui :as ui]
    [frontend.handler.notification :as notification]
-   [frontend.handler.web.nfs :as web-nfs]
+   [frontend.handler.file-based.nfs :as nfs-handler]
    [frontend.handler.page :as page-handler]
    [frontend.util :as util]
    [frontend.modules.shortcut.core :as shortcut]
@@ -63,7 +63,7 @@
                                                    (p/resolved nil))))
                                        (p/then
                                         (fn []
-                                          (web-nfs/ls-dir-files-with-path!
+                                          (nfs-handler/ls-dir-files-with-path!
                                            graph-path (merge
                                                        {:ok-handler
                                                         (fn []

+ 2 - 2
src/test/frontend/handler/repo_test.cljs

@@ -1,6 +1,6 @@
 (ns frontend.handler.repo-test
   (:require [cljs.test :refer [deftest use-fixtures testing is]]
-            [frontend.handler.repo :as repo-handler]
+            [frontend.handler.file-based.repo :as file-repo-handler]
             [frontend.test.helper :as test-helper :refer [load-test-files]]
             [logseq.graph-parser.cli :as gp-cli]
             [logseq.graph-parser.test.docs-graph-helper :as docs-graph-helper]
@@ -19,7 +19,7 @@
         repo-config (edn/read-string (str (fs/readFileSync (node-path/join graph-dir "logseq/config.edn"))))
         files (#'gp-cli/build-graph-files graph-dir repo-config)
         _ (test-helper/with-config repo-config
-            (repo-handler/parse-files-and-load-to-db! test-helper/test-db files {:re-render? false :verbose false}))
+            (file-repo-handler/parse-files-and-load-to-db! test-helper/test-db files {:re-render? false :verbose false}))
         db (conn/get-db test-helper/test-db)]
 
     (docs-graph-helper/docs-graph-assertions db graph-dir (map :file/path files))))

+ 3 - 3
src/test/frontend/test/helper.cljs

@@ -1,6 +1,6 @@
 (ns frontend.test.helper
   "Common helper fns for tests"
-  (:require [frontend.handler.repo :as repo-handler]
+  (:require [frontend.handler.file-based.repo :as file-repo-handler]
             [frontend.state :as state]
             [frontend.db.conn :as conn]
             [clojure.string :as string]
@@ -114,7 +114,7 @@
   [files*]
   (let [files (mapv update-file-for-db-graph files*)]
     ;; TODO: Use sqlite instead of file graph to create client db
-    (repo-handler/parse-files-and-load-to-db!
+    (file-repo-handler/parse-files-and-load-to-db!
      test-db
      files
      {:re-render? false :verbose false :refresh? true})
@@ -196,7 +196,7 @@ This can be called in synchronous contexts as no async fns should be invoked"
   [files]
   (if js/process.env.DB_GRAPH
     (load-test-files-for-db-graph files)
-    (repo-handler/parse-files-and-load-to-db!
+    (file-repo-handler/parse-files-and-load-to-db!
      test-db
      files
    ;; Set :refresh? to avoid creating default files in after-parse