Clone Group.Data and Client.Data.
This avoids a race condition. Thanks to git-lul.
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
|
"maps"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -133,7 +134,7 @@ func (g *Group) SetLocked(locked bool, message string) {
|
|||||||
func (g *Group) Data() map[string]interface{} {
|
func (g *Group) Data() map[string]interface{} {
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
defer g.mu.Unlock()
|
defer g.mu.Unlock()
|
||||||
return g.data
|
return maps.Clone(g.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) UpdateData(d map[string]interface{}) {
|
func (g *Group) UpdateData(d map[string]interface{}) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"maps"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -101,7 +102,7 @@ func (c *webClient) Permissions() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *webClient) Data() map[string]interface{} {
|
func (c *webClient) Data() map[string]interface{} {
|
||||||
return c.data
|
return maps.Clone(c.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *webClient) SetPermissions(perms []string) {
|
func (c *webClient) SetPermissions(perms []string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user