mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Make sure the cache lookup returns always the same result
This commit is contained in:
parent
360078d761
commit
1d4b7d8fa1
1 changed files with 5 additions and 7 deletions
12
server.go
12
server.go
|
@ -21,6 +21,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -1694,16 +1695,13 @@ func (srv *Server) ImageGetCached(imgID string, config *Config) (*Image, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the tree in a map of map (map[parentId][childId])
|
// Store the tree in a map of map (map[parentId][childId])
|
||||||
imageMap := make(map[string]map[string]struct{})
|
imageMap := make(map[string][]string)
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
if _, exists := imageMap[img.Parent]; !exists {
|
imageMap[img.Parent] = append(imageMap[img.Parent], img.ID)
|
||||||
imageMap[img.Parent] = make(map[string]struct{})
|
|
||||||
}
|
}
|
||||||
imageMap[img.Parent][img.ID] = struct{}{}
|
sort.Strings(imageMap[imgID])
|
||||||
}
|
|
||||||
|
|
||||||
// Loop on the children of the given image and check the config
|
// Loop on the children of the given image and check the config
|
||||||
for elem := range imageMap[imgID] {
|
for _, elem := range imageMap[imgID] {
|
||||||
img, err := srv.runtime.graph.Get(elem)
|
img, err := srv.runtime.graph.Get(elem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue