fix: do not overwrite .md file if it already exist

close #1332
This commit is contained in:
Tienson Qin
2022-08-04 21:01:25 +08:00
parent 59b924f25d
commit f1ee980e47
2 changed files with 9 additions and 2 deletions

View File

@@ -203,8 +203,11 @@
file (.getFile file-handle)]
(when file
(nfs-saved-handler repo path file)))
(notification/show! (str "The file " path " already exists, please save your changes and click the refresh button to reload it.")
:warning)))
(do
(notification/show! (str "The file " path " already exists, please append the content if you need it.\n Unsaved content: \n" content)
:warning
false)
(state/pub-event! [:file/alter repo path text]))))
(println "Error: directory handle not exists: " handle-path)))
(p/catch (fn [error]
(println "Write local file failed: " {:path path})

View File

@@ -521,6 +521,10 @@
(when (= dir (config/get-repo-dir repo))
(fs/watch-dir! dir)))
(defmethod handle :file/alter [[_ repo path content]]
(p/let [_ (file-handler/alter-file repo path content {:from-disk? true})]
(ui-handler/re-render-root!)))
(defn run!
[]
(let [chan (state/get-events-chan)]