Jelajahi Sumber

Revert "Make sure the cache lookup returns always the same result"

This reverts commit 1d4b7d8fa1af95ce83f263a49ed24e686fa7cb62.

Docker-DCO-1.0-Signed-off-by: Sjoerd Langkemper <sjoerd@byte.nl> (github: Sjord)
Sjoerd Langkemper 11 tahun lalu
induk
melakukan
10b794b332
1 mengubah file dengan 7 tambahan dan 5 penghapusan
  1. 7 5
      server.go

+ 7 - 5
server.go

@@ -22,7 +22,6 @@ import (
 	"path"
 	"path/filepath"
 	"runtime"
-	"sort"
 	"strconv"
 	"strings"
 	"sync"
@@ -1697,13 +1696,16 @@ func (srv *Server) ImageGetCached(imgID string, config *Config) (*Image, error)
 	}
 
 	// Store the tree in a map of map (map[parentId][childId])
-	imageMap := make(map[string][]string)
+	imageMap := make(map[string]map[string]struct{})
 	for _, img := range images {
-		imageMap[img.Parent] = append(imageMap[img.Parent], img.ID)
+		if _, exists := imageMap[img.Parent]; !exists {
+			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
-	for _, elem := range imageMap[imgID] {
+	for elem := range imageMap[imgID] {
 		img, err := srv.runtime.graph.Get(elem)
 		if err != nil {
 			return nil, err