Parcourir la source

fix: ignore files when load graph files

Tienson Qin il y a 3 ans
Parent
commit
158b6e07be
1 fichiers modifiés avec 18 ajouts et 14 suppressions
  1. 18 14
      src/main/frontend/fs/watcher_handler.cljs

+ 18 - 14
src/main/frontend/fs/watcher_handler.cljs

@@ -16,7 +16,9 @@
             [promesa.core :as p]
             [frontend.state :as state]
             [frontend.fs :as fs]
-            [frontend.fs.capacitor-fs :as capacitor-fs]))
+            [frontend.fs.capacitor-fs :as capacitor-fs]
+            [frontend.util.fs :as fs-util]
+            [frontend.util :as util]))
 
 ;; all IPC paths must be normalized! (via gp-util/path-normalize)
 
@@ -120,16 +122,18 @@
     (let [dir (config/get-repo-dir graph)]
       (p/let [files (fs/readdir dir :path-only? true)]
         (doseq [file files]
-          (->
-           (p/let [content (fs/read-file dir file)
-                   stat (fs/stat dir file)
-                   type (if (db/file-exists? graph file)
-                          "change"
-                          "add")]
-             (handle-changed! type
-                              {:dir dir
-                               :path file
-                               :content content
-                               :stat stat}))
-           (p/catch (fn [error]
-                      (js/console.dir error)))))))))
+          (when-let [ext (util/get-file-ext file)]
+            (->
+            (when-not (fs-util/ignored-path? dir file)
+              (p/let [content (fs/read-file dir file)
+                      stat (fs/stat dir file)
+                      type (if (db/file-exists? graph file)
+                             "change"
+                             "add")]
+                (handle-changed! type
+                                 {:dir dir
+                                  :path file
+                                  :content content
+                                  :stat stat})))
+            (p/catch (fn [error]
+                       (js/console.dir error))))))))))