0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-11 09:38:56 -05:00

🐛 Fix possible race condition on component rename and deletion

This commit is contained in:
Andrey Antukh 2022-02-15 11:13:16 +01:00 committed by Andrés Moya
parent ce61b783fb
commit 82796822d1
2 changed files with 24 additions and 20 deletions

View file

@ -5,6 +5,7 @@
### :bug: Bugs fixed ### :bug: Bugs fixed
- Fix issue on handling empty content on boolean shapes - Fix issue on handling empty content on boolean shapes
- Fix race condition issue on component renaming
- Handle EOF errors on writting streamed response - Handle EOF errors on writting streamed response
- Handle EOF errors on websocket send/ping methods - Handle EOF errors on websocket send/ping methods
- Disable parallel upload of file media on import (causes too much - Disable parallel upload of file media on import (causes too much

View file

@ -314,10 +314,13 @@
(ptk/reify ::rename-component (ptk/reify ::rename-component
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
;; NOTE: we need to ensure the component exists, because there
;; are small posibilities of race conditions with component
;; deletion.
(when-let [component (get-in state [:workspace-data :components id])]
(let [[path name] (cp/parse-path-name new-name) (let [[path name] (cp/parse-path-name new-name)
component (get-in state [:workspace-data :components id])
objects (get component :objects) objects (get component :objects)
; Give the same name to the root shape ;; Give the same name to the root shape
new-objects (assoc-in objects new-objects (assoc-in objects
[(:id component) :name] [(:id component) :name]
name) name)
@ -336,7 +339,7 @@
(rx/of (dch/commit-changes {:redo-changes rchanges (rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges :undo-changes uchanges
:origin it})))))) :origin it})))))))
(defn duplicate-component (defn duplicate-component
"Create a new component copied from the one with the given id." "Create a new component copied from the one with the given id."