mirror of
https://github.com/penpot/penpot.git
synced 2025-05-06 21:45:58 +02:00
Merge pull request #4714 from penpot/niwinz-persistence-bugfix-1
🐛 Fix race condition between shape modifiation and persistence
This commit is contained in:
commit
4db189f90d
2 changed files with 8 additions and 9 deletions
|
@ -69,9 +69,10 @@
|
||||||
(cpc/check-changes! undo-changes)))
|
(cpc/check-changes! undo-changes)))
|
||||||
|
|
||||||
(let [commit-id (or commit-id (uuid/next))
|
(let [commit-id (or commit-id (uuid/next))
|
||||||
|
source (d/nilv source :local)
|
||||||
commit {:id commit-id
|
commit {:id commit-id
|
||||||
:created-at (dt/now)
|
:created-at (dt/now)
|
||||||
:source (d/nilv source :local)
|
:source source
|
||||||
:origin (ptk/type origin)
|
:origin (ptk/type origin)
|
||||||
:features features
|
:features features
|
||||||
:file-id file-id
|
:file-id file-id
|
||||||
|
@ -110,9 +111,7 @@
|
||||||
|
|
||||||
redo-changes (if pending
|
redo-changes (if pending
|
||||||
(into redo-changes
|
(into redo-changes
|
||||||
(comp
|
(mapcat :redo-changes)
|
||||||
(map :redo-changes)
|
|
||||||
(mapcat identity))
|
|
||||||
pending)
|
pending)
|
||||||
redo-changes)]
|
redo-changes)]
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
(log/debug :hint "initialize persistence")
|
(log/debug :hint "initialize persistence")
|
||||||
(let [stoper-s (rx/filter (ptk/type? ::initialize-persistence) stream)
|
(let [stoper-s (rx/filter (ptk/type? ::initialize-persistence) stream)
|
||||||
|
|
||||||
commits-s
|
local-commits-s
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter dch/commit?)
|
(rx/filter dch/commit?)
|
||||||
(rx/map deref)
|
(rx/map deref)
|
||||||
|
@ -192,20 +192,20 @@
|
||||||
|
|
||||||
notifier-s
|
notifier-s
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> commits-s
|
(->> local-commits-s
|
||||||
(rx/debounce 3000)
|
(rx/debounce 3000)
|
||||||
(rx/tap #(log/trc :hint "persistence beat")))
|
(rx/tap #(log/trc :hint "persistence beat")))
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter #(= % ::force-persist))))]
|
(rx/filter #(= % ::force-persist))))]
|
||||||
|
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> commits-s
|
(->> local-commits-s
|
||||||
(rx/debounce 200)
|
(rx/debounce 200)
|
||||||
(rx/map (fn [_]
|
(rx/map (fn [_]
|
||||||
(update-status :pending)))
|
(update-status :pending)))
|
||||||
(rx/take-until stoper-s))
|
(rx/take-until stoper-s))
|
||||||
|
|
||||||
(->> commits-s
|
(->> local-commits-s
|
||||||
(rx/buffer-time 200)
|
(rx/buffer-time 200)
|
||||||
(rx/mapcat merge-commit)
|
(rx/mapcat merge-commit)
|
||||||
(rx/map dch/update-indexes)
|
(rx/map dch/update-indexes)
|
||||||
|
@ -216,7 +216,7 @@
|
||||||
;; Here we watch for local commits, buffer them in a small
|
;; Here we watch for local commits, buffer them in a small
|
||||||
;; chunks (very near in time commits) and append them to the
|
;; chunks (very near in time commits) and append them to the
|
||||||
;; persistence queue
|
;; persistence queue
|
||||||
(->> commits-s
|
(->> local-commits-s
|
||||||
(rx/buffer-until notifier-s)
|
(rx/buffer-until notifier-s)
|
||||||
(rx/mapcat merge-commit)
|
(rx/mapcat merge-commit)
|
||||||
(rx/map append-commit)
|
(rx/map append-commit)
|
||||||
|
|
Loading…
Add table
Reference in a new issue