Quellcode durchsuchen

fix: local page history not working

Tienson Qin vor 3 Jahren
Ursprung
Commit
d4ba355c62
1 geänderte Dateien mit 19 neuen und 11 gelöschten Zeilen
  1. 19 11
      src/main/frontend/handler/file_sync.cljs

+ 19 - 11
src/main/frontend/handler/file_sync.cljs

@@ -15,7 +15,8 @@
             [cljs-time.coerce :as tc]
             [cljs-time.core :as t]
             [frontend.storage :as storage]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.graph-parser.util :as gp-util]
+            [lambdaisland.glogi :as log]))
 
 (def *beta-unavailable? (volatile! false))
 
@@ -142,18 +143,25 @@
                                      (#(js->clj % :keywordize-keys true))
                                      ((juxt :dir :name))
                                      (apply path/join base-path))
-            version-file-paths (<! (p->c (fs/readdir version-files-dir :path-only? true)))]
+            version-file-paths (->> (<! (p->c (fs/readdir version-files-dir :path-only? true)))
+                                    (remove #{version-files-dir}))]
         (when-not (instance? ExceptionInfo version-file-paths)
           (when (seq version-file-paths)
-            (mapv
-             (fn [path]
-               (let [create-time
-                     (-> (path/parse path)
-                         (js->clj :keywordize-keys true)
-                         :name
-                         (#(tf/parse (tf/formatter "yyyy-MM-dd'T'HH_mm_ss.SSSZZ") %)))]
-                 {:create-time create-time :path path :relative-path (string/replace-first path base-path "")}))
-             version-file-paths)))))))
+            (->>
+             (mapv
+              (fn [path]
+                (try
+                  (let [create-time
+                       (-> (path/parse path)
+                           (js->clj :keywordize-keys true)
+                           :name
+                           (#(tf/parse (tf/formatter "yyyy-MM-dd'T'HH_mm_ss.SSSZZ") %)))]
+                    {:create-time create-time :path path :relative-path (string/replace-first path base-path "")})
+                  (catch :default e
+                    (log/error :page-history/parse-format-error e)
+                    nil)))
+              version-file-paths)
+             (remove nil?))))))))
 
 (defn fetch-page-file-versions [graph-uuid page]
   []