fix: reuse page uuids when parsing files

This commit also removes `with-id?` because it's too confusing.

Fixes LOG-3143
This commit is contained in:
Tienson Qin
2024-06-15 22:52:30 +08:00
parent 4281274512
commit b294896f8a
16 changed files with 143 additions and 139 deletions

View File

@@ -15,8 +15,9 @@
(assert (uuid? uuid) (str "rtc-create-page! `uuid` is not a uuid " uuid))
(let [date-formatter (common-config/get-date-formatter config)
[title page-name] (db-worker-page/get-title-and-pagename title)
page (-> (gp-block/page-name->map title uuid @conn true date-formatter
{:skip-existing-page-check? true})
page (-> (gp-block/page-name->map title @conn true date-formatter
{:page-uuid uuid
:skip-existing-page-check? true})
(assoc :block/format :markdown))
result (ldb/transact! conn [page] {:persist-op? false
:outliner-op :create-page})]

View File

@@ -68,11 +68,12 @@
persist-op? true}
:as options}]
(let [date-formatter (common-config/get-date-formatter config)
[title page-name] (get-title-and-pagename title)
with-uuid? (if (uuid? uuid) uuid true)]
[title page-name] (get-title-and-pagename title)]
(when-not (ldb/get-case-page @conn page-name)
(let [format :markdown
page (-> (gp-block/page-name->map title with-uuid? @conn true date-formatter :class? class?)
page (-> (gp-block/page-name->map title @conn true date-formatter
{:class? class?
:page-uuid (when (uuid? uuid) uuid)})
(assoc :block/format format))
page-uuid (:block/uuid page)
page-txs (build-page-tx conn properties page (select-keys options [:whiteboard? :class? :tags]))
@@ -90,4 +91,4 @@
today-journal?
(assoc :create-today-journal? true
:today-journal-name page-name)))])]
[result page-name page-uuid]))))
[result page-name page-uuid]))))

View File

@@ -75,8 +75,7 @@
(let [date-formatter (common-config/get-date-formatter config)
split-namespace? (not (or (string/starts-with? title "hls__")
(date/valid-journal-title? date-formatter title)))
[title page-name] (get-title-and-pagename title)
with-uuid? (if (uuid? uuid) uuid true)]
[title page-name] (get-title-and-pagename title)]
(when-not (ldb/get-page @conn page-name)
(let [pages (if split-namespace?
(common-util/split-namespace-pages title)
@@ -84,7 +83,8 @@
format (or format (common-config/get-preferred-format config))
pages (map (fn [page]
;; only apply uuid to the deepest hierarchy of page to create if provided.
(-> (gp-block/page-name->map page (if (= page title) with-uuid? true) @conn true date-formatter)
(-> (gp-block/page-name->map page @conn true date-formatter
{:page-uuid (when (uuid? uuid) uuid)})
(assoc :block/format format)))
pages)
txs (->> pages