diff --git a/src/main/frontend/handler/conversion.cljs b/src/main/frontend/handler/conversion.cljs index c5b51e443..26dc6b14d 100644 --- a/src/main/frontend/handler/conversion.cljs +++ b/src/main/frontend/handler/conversion.cljs @@ -4,7 +4,8 @@ "For conversion logic between old version and new version" (:require [logseq.graph-parser.util :as gp-util] [frontend.util.fs :as fs-util] - [frontend.handler.config :refer [set-config!]])) + [frontend.handler.config :refer [set-config!]] + [frontend.util :as util])) (defn write-filename-format! "Return: @@ -77,11 +78,16 @@ ;; It's about user's own data management decision and should be handled ;; by user manually. ;; the 'expected' title of the user when updating from the previous format, or title will be broken in new format - (or (when (and (nil? prop-title) - (not= old-format new-format)) - (calc-previous-name old-format new-format file-body)) - ;; if no break-change conversion triggered, check if file name is in an informal / outdated style. - (calc-current-name new-format file-body prop-title))) + (let [ret (or (when (and (nil? prop-title) + (not= old-format new-format)) + (calc-previous-name old-format new-format file-body)) + ;; if no break-change conversion triggered, check if file name is in an informal / outdated style. + (calc-current-name new-format file-body prop-title))] + (when (and ret + ;; Return only when the target is different from the original file body, not only capitalization difference + (not= (util/page-name-sanity-lc (:target ret)) + (util/page-name-sanity-lc file-body))) + ret))) (defn calc-rename-target "Return the renaming status and new file body to recover the original title of the file in previous version. diff --git a/src/test/frontend/db/name_sanity_test.cljs b/src/test/frontend/db/name_sanity_test.cljs index 03b19b2e9..3c97bce92 100644 --- a/src/test/frontend/db/name_sanity_test.cljs +++ b/src/test/frontend/db/name_sanity_test.cljs @@ -102,6 +102,7 @@ (deftest rename-tests ;; z: new title structure; x: old ver title; y: title property (if available) (are [x y z] (= z (#'conversion-handler/calc-rename-target-impl :legacy :triple-lowbar x y)) + "aaBBcc" "aabbcc" nil "aaa.bbb.ccc" "aaa/bbb/ccc" {:status :informal, :target "aaa___bbb___ccc", :old-title "aaa/bbb/ccc",