Răsfoiți Sursa

fix(fs): handle parsing state of empty folder

Andelf 2 ani în urmă
părinte
comite
50585d215f
2 a modificat fișierele cu 8 adăugiri și 9 ștergeri
  1. 1 2
      src/main/frontend/fs2/path.cljs
  2. 7 7
      src/main/frontend/handler/repo.cljs

+ 1 - 2
src/main/frontend/fs2/path.cljs

@@ -2,7 +2,6 @@
   "Path manipulation functions, use '/' on all platforms.
    Also handles URL paths."
   (:require [clojure.string :as string]
-            [goog :refer [Uri]]
             [logseq.graph-parser.util :as gp-util]))
 
 
@@ -205,7 +204,7 @@
   "Get relative path from base path.
    Works for both path and URL."
   [base-path sub-path]
-    (prn :rel-path base-path sub-path)
+  (prn :rel-path base-path sub-path)
   (let [base-path (path-normalize base-path)
         sub-path (path-normalize sub-path)
         is-url? (is-file-url base-path)]

+ 7 - 7
src/main/frontend/handler/repo.cljs

@@ -221,7 +221,7 @@
                           (assoc opts' :skip-db-transact? false)
                           opts')
                   result (parse-and-load-file! repo-url file opts')
-                  page-name (some (fn [x] (when (and (map? x) (:block/original-name x )
+                  page-name (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))
@@ -262,11 +262,11 @@
 
 
 (defn load-new-repo-to-db!
-  "load graph files 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---- file-objs repo-url)
+  (prn ::load---new-file-objs repo-url)
   (state/set-parsing-state! {:graph-loading? true})
   (let [repo-dir (config/get-local-dir repo-url)
         _ (prn ::repo-dir repo-dir)
@@ -274,15 +274,15 @@
                                               :file/content)]
                      (repo-config-handler/read-repo-config content))
                    (state/get-config repo-url))
-        _ (prn ::repo-config config)
         ;; 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-handler/remove-hidden-files file-objs config :file/path)]
-    (when (seq file-objs)
+    (if (seq file-objs)
       (parse-files-and-load-to-db! repo-url file-objs {:new-graph? new-graph?
-                                                       :empty-graph? empty-graph?}))))
+                                                       :empty-graph? empty-graph?})
+      (state/set-parsing-state! {:graph-loading? false}))))
 
 
 
@@ -290,7 +290,7 @@
   [repo-url {:keys [diffs file-objs refresh? new-graph? empty-graph?]}]
   (spec/validate :repos/url repo-url)
   (route-handler/redirect-to-home!)
-  (prn ::load---- file-objs)
+  (prn ::load----file-objs file-objs)
   (state/set-parsing-state! {:graph-loading? true})
   (let [repo-dir (config/get-local-dir repo-url)
         _ (prn ::repo-dir repo-dir)