Browse Source

enhance: detect file changes when starting

Tienson Qin 4 years ago
parent
commit
d94ce5e78b

+ 1 - 1
src/electron/electron/fs_watcher.cljs

@@ -26,7 +26,7 @@
                           (clj->js
                            {:ignored (fn [path]
                                        (utils/ignored-path? dir path))
-                            :ignoreInitial true
+                            :ignoreInitial false
                             :ignorePermissionErrors true
                             :interval polling-interval
                             :binaryInterval polling-interval

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

@@ -194,6 +194,10 @@
          (search/search)
          [:div.flex-1])
 
+       [:a (when refreshing?
+             [:div {:class "animate-spin-reverse"}
+              svg/refresh])]
+
        (when electron-mac?
          (logo {:white? white?
                 :electron-mac? true}))
@@ -202,10 +206,6 @@
 
        (new-block-mode)
 
-       (when refreshing?
-         [:div {:class "animate-spin-reverse"}
-          svg/refresh])
-
        (when-not (util/electron?)
          (login logged?))
 

+ 5 - 1
src/main/frontend/dicts.cljs

@@ -251,7 +251,7 @@
         :close "Close"
         :delete "Delete"
         :re-index "Re-index (rebuild the graph)"
-        :sync-from-local-files "Sync from local files"
+        :sync-from-local-files "Refresh (Import changes from local files)"
         :unlink "unlink"
         :search (if config/publishing?
                   "Search"
@@ -931,7 +931,9 @@
            :yes "是"
            :submit "提交"
            :cancel "取消"
+           :new-graph "添加图谱"
            :re-index "重新建立索引"
+           :sync-from-local-files "刷新(读取本地最新文件)"
            :export-json "以 JSON 格式导出"
            :export-roam-json "以 Roam JSON 格式导出"
            :export-markdown "以 Markdown 格式导出"
@@ -947,6 +949,8 @@
            :new-file "新文件"
            :graph "图谱"
            :graph-view "全局图谱"
+           :cards-view "卡片组"
+           :all-journals "日记"
            :publishing "发布"
            :export "导出"
            :all-graphs "所有库"

+ 7 - 6
src/main/frontend/fs/watcher_handler.cljs

@@ -37,12 +37,13 @@
           db-content (or (db/get-file repo path) "")]
       (when (and content (not (encrypt/content-encrypted? content)))
         (cond
-          (= "add" type)
-          (when-not (db/file-exists? repo path)
-            (p/let [_ (file-handler/alter-file repo path content {:re-render-root? true
-                                                                  :from-disk? true})]
-              (set-missing-block-ids! content)
-              (db/set-file-last-modified-at! repo path mtime)))
+          (and (= "add" type)
+               (not= (string/trim content) (string/trim db-content))
+               (not (string/includes? path "logseq/pages-metadata.edn")))
+          (p/let [_ (file-handler/alter-file repo path content {:re-render-root? true
+                                                                :from-disk? true})]
+            (set-missing-block-ids! content)
+            (db/set-file-last-modified-at! repo path mtime))
 
           (and (= "change" type)
                (not (db/file-exists? repo path)))