lib/api: Add missing config mod. locks (ref #7001) (#7053)

This commit is contained in:
Simon Frei 2020-10-23 10:34:20 +02:00 committed by GitHub
parent a20d85d451
commit 9189c79d74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,6 +153,8 @@ func (c *configMuxBuilder) registerFolder(path string) {
}) })
c.Handle(http.MethodDelete, path, func(w http.ResponseWriter, _ *http.Request, p httprouter.Params) { c.Handle(http.MethodDelete, path, func(w http.ResponseWriter, _ *http.Request, p httprouter.Params) {
c.mut.Lock()
defer c.mut.Unlock()
waiter, err := c.cfg.RemoveFolder(p.ByName("id")) waiter, err := c.cfg.RemoveFolder(p.ByName("id"))
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
@ -194,6 +196,8 @@ func (c *configMuxBuilder) registerDevice(path string) {
}) })
c.Handle(http.MethodDelete, path, func(w http.ResponseWriter, _ *http.Request, p httprouter.Params) { c.Handle(http.MethodDelete, path, func(w http.ResponseWriter, _ *http.Request, p httprouter.Params) {
c.mut.Lock()
defer c.mut.Unlock()
id, err := protocol.DeviceIDFromString(p.ByName("id")) id, err := protocol.DeviceIDFromString(p.ByName("id"))
waiter, err := c.cfg.RemoveDevice(id) waiter, err := c.cfg.RemoveDevice(id)
if err != nil { if err != nil {