0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

Merge pull request #4714 from penpot/niwinz-persistence-bugfix-1

🐛 Fix race condition between shape modifiation and persistence
This commit is contained in:
Alejandro 2024-06-11 07:26:02 +02:00 committed by GitHub
commit 4db189f90d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View file

@ -69,9 +69,10 @@
(cpc/check-changes! undo-changes)))
(let [commit-id (or commit-id (uuid/next))
source (d/nilv source :local)
commit {:id commit-id
:created-at (dt/now)
:source (d/nilv source :local)
:source source
:origin (ptk/type origin)
:features features
:file-id file-id
@ -110,9 +111,7 @@
redo-changes (if pending
(into redo-changes
(comp
(map :redo-changes)
(mapcat identity))
(mapcat :redo-changes)
pending)
redo-changes)]

View file

@ -182,7 +182,7 @@
(log/debug :hint "initialize persistence")
(let [stoper-s (rx/filter (ptk/type? ::initialize-persistence) stream)
commits-s
local-commits-s
(->> stream
(rx/filter dch/commit?)
(rx/map deref)
@ -192,20 +192,20 @@
notifier-s
(rx/merge
(->> commits-s
(->> local-commits-s
(rx/debounce 3000)
(rx/tap #(log/trc :hint "persistence beat")))
(->> stream
(rx/filter #(= % ::force-persist))))]
(rx/merge
(->> commits-s
(->> local-commits-s
(rx/debounce 200)
(rx/map (fn [_]
(update-status :pending)))
(rx/take-until stoper-s))
(->> commits-s
(->> local-commits-s
(rx/buffer-time 200)
(rx/mapcat merge-commit)
(rx/map dch/update-indexes)
@ -216,7 +216,7 @@
;; Here we watch for local commits, buffer them in a small
;; chunks (very near in time commits) and append them to the
;; persistence queue
(->> commits-s
(->> local-commits-s
(rx/buffer-until notifier-s)
(rx/mapcat merge-commit)
(rx/map append-commit)