فهرست منبع

fix: no need to check file exists when transaction blocks

Because it'll check the last modified timestamp when writing the file.
Tienson Qin 4 سال پیش
والد
کامیت
b74184610d
1فایلهای تغییر یافته به همراه13 افزوده شده و 19 حذف شده
  1. 13 19
      src/main/frontend/modules/file/core.cljs

+ 13 - 19
src/main/frontend/modules/file/core.cljs

@@ -121,25 +121,19 @@
                 (if (= format "markdown") "md" format))
                 (if (= format "markdown") "md" format))
           file-path (str "/" path)
           file-path (str "/" path)
           dir (config/get-repo-dir repo)]
           dir (config/get-repo-dir repo)]
-      (p/let [exists? (fs/file-exists? dir file-path)]
-        (if exists?
-          (notification/show!
-           [:p.content
-            (util/format "File %s already exists!" file-path)]
-           :error)
-          (let [file-path (config/get-file-path repo path)
-                page-blocks (db/get-page-blocks-no-cache (:block/name page))
-                tx (->>
-                    (concat
-                     [{:file/path file-path}
-                      {:block/name (:block/name page)
-                       :block/file [:file/path file-path]}]
-                     (map (fn [block] {:db/id (:db/id block)
-                                      :block/file [:file/path file-path]})
-                       page-blocks))
-                    (remove nil?))]
-            (db/transact! tx)
-            (when ok-handler (ok-handler))))))))
+      (let [file-path (config/get-file-path repo path)
+            page-blocks (db/get-page-blocks-no-cache (:block/name page))
+            tx (->>
+                (concat
+                 [{:file/path file-path}
+                  {:block/name (:block/name page)
+                   :block/file [:file/path file-path]}]
+                 (map (fn [block] {:db/id (:db/id block)
+                                   :block/file [:file/path file-path]})
+                   page-blocks))
+                (remove nil?))]
+        (db/transact! tx)
+        (when ok-handler (ok-handler))))))
 
 
 (defn save-tree-aux!
 (defn save-tree-aux!
   [page-block tree]
   [page-block tree]