fix: check asset exists before transacting checksum

related to https://github.com/logseq/db-test/issues/415
This commit is contained in:
Tienson Qin
2025-08-10 12:47:51 +08:00
parent 123d03f293
commit 7685760aff

View File

@@ -140,11 +140,13 @@
repo (str asset-uuid) asset-type checksum url))]
(when (:ex-data r)
(throw (ex-info "upload asset failed" r)))
(d/transact! conn
[{:block/uuid asset-uuid
:logseq.property.asset/remote-metadata {:checksum checksum :type asset-type}}]
;; Don't generate rtc ops again, (block-ops & asset-ops)
{:persist-op? false})
;; asset might be deleted by the server before uploaded successfully
(when (d/entity @conn [:block/uuid asset-uuid])
(d/transact! conn
[{:block/uuid asset-uuid
:logseq.property.asset/remote-metadata {:checksum checksum :type asset-type}}]
;; Don't generate rtc ops again, (block-ops & asset-ops)
{:persist-op? false}))
(client-op/remove-asset-op repo asset-uuid))))
(c.m/concurrent-exec-flow 3 (m/seed asset-uuid->url))
(m/reduce (constantly nil))))