Просмотр исходного кода

fix: check asset exists before transacting checksum

related to https://github.com/logseq/db-test/issues/415
Tienson Qin 4 месяцев назад
Родитель
Сommit
7685760aff
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      src/main/frontend/worker/rtc/asset.cljs

+ 7 - 5
src/main/frontend/worker/rtc/asset.cljs

@@ -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))))