mirror of
https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
synced 2024-11-22 07:06:25 +00:00
Fix race condition in AppConfig
This commit is contained in:
parent
712c7a008a
commit
7772f3b68d
@ -21,12 +21,12 @@ unit_tests:
|
|||||||
script:
|
script:
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
#race_detector:
|
race_detector:
|
||||||
# stage: test
|
stage: test
|
||||||
# tags:
|
tags:
|
||||||
# - docker
|
- docker
|
||||||
# script:
|
script:
|
||||||
# - make race
|
- make race
|
||||||
|
|
||||||
code_coverage:
|
code_coverage:
|
||||||
stage: test
|
stage: test
|
||||||
|
@ -59,8 +59,8 @@ func (c *Client) AppsConfigDeleteValue(id, key, value string) error {
|
|||||||
|
|
||||||
//AppsConfig returns all apps AppConfigDetails
|
//AppsConfig returns all apps AppConfigDetails
|
||||||
func (c *Client) AppsConfig() (map[string]map[string]string, error) {
|
func (c *Client) AppsConfig() (map[string]map[string]string, error) {
|
||||||
config := make(map[string]map[string]string)
|
config := map[string]map[string]string{}
|
||||||
var err error
|
m := sync.Mutex{}
|
||||||
appsIDs, err := c.AppsConfigList()
|
appsIDs, err := c.AppsConfigList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -72,7 +72,9 @@ func (c *Client) AppsConfig() (map[string]map[string]string, error) {
|
|||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
d, err := c.AppsConfigDetails(id)
|
d, err := c.AppsConfigDetails(id)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
m.Lock()
|
||||||
config[id] = d
|
config[id] = d
|
||||||
|
m.Unlock()
|
||||||
}
|
}
|
||||||
}(appsIDs[i])
|
}(appsIDs[i])
|
||||||
}
|
}
|
||||||
@ -82,7 +84,8 @@ func (c *Client) AppsConfig() (map[string]map[string]string, error) {
|
|||||||
|
|
||||||
//AppsConfigDetails returns all the config's key, values pair of the app
|
//AppsConfigDetails returns all the config's key, values pair of the app
|
||||||
func (c *Client) AppsConfigDetails(appID string) (map[string]string, error) {
|
func (c *Client) AppsConfigDetails(appID string) (map[string]string, error) {
|
||||||
config := make(map[string]string)
|
config := map[string]string{}
|
||||||
|
m := sync.Mutex{}
|
||||||
var err error
|
var err error
|
||||||
var ks []string
|
var ks []string
|
||||||
ks, err = c.AppsConfigKeys(appID)
|
ks, err = c.AppsConfigKeys(appID)
|
||||||
@ -94,10 +97,11 @@ func (c *Client) AppsConfigDetails(appID string) (map[string]string, error) {
|
|||||||
for i := range ks {
|
for i := range ks {
|
||||||
go func(key string) {
|
go func(key string) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
var v string
|
v, err := c.AppsConfigValue(appID, key)
|
||||||
v, err = c.AppsConfigValue(appID, key)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
m.Lock()
|
||||||
config[key] = v
|
config[key] = v
|
||||||
|
m.Unlock()
|
||||||
}
|
}
|
||||||
}(ks[i])
|
}(ks[i])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user