mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-09-04 06:34:51 +00:00
Fix concurrent map iteration and map write
This commit is contained in:
@@ -280,11 +280,15 @@ func (c *Client) SubRepoTagCounts(repoPath string, repos []string) map[string]in
|
|||||||
if repoPath != "" {
|
if repoPath != "" {
|
||||||
subRepo = repoPath + "/" + r
|
subRepo = repoPath + "/" + r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Acquire lock to prevent concurrent map iteration and map write.
|
||||||
|
c.tagCountsMux.Lock()
|
||||||
for k, v := range c.tagCounts {
|
for k, v := range c.tagCounts {
|
||||||
if k == subRepo || strings.HasPrefix(k, subRepo+"/") {
|
if k == subRepo || strings.HasPrefix(k, subRepo+"/") {
|
||||||
counts[subRepo] = counts[subRepo] + v
|
counts[subRepo] = counts[subRepo] + v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.tagCountsMux.Unlock()
|
||||||
}
|
}
|
||||||
return counts
|
return counts
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user