github.com/xdlianrong208/docker-ce-comments@v17.12.1-ce-rc2+incompatible/components/engine/layer/layer_windows.go (about) 1 package layer 2 3 import ( 4 "errors" 5 ) 6 7 // Getter is an interface to get the path to a layer on the host. 8 type Getter interface { 9 // GetLayerPath gets the path for the layer. This is different from Get() 10 // since that returns an interface to account for umountable layers. 11 GetLayerPath(id string) (string, error) 12 } 13 14 // GetLayerPath returns the path to a layer 15 func GetLayerPath(s Store, layer ChainID) (string, error) { 16 ls, ok := s.(*layerStore) 17 if !ok { 18 return "", errors.New("unsupported layer store") 19 } 20 ls.layerL.Lock() 21 defer ls.layerL.Unlock() 22 23 rl, ok := ls.layerMap[layer] 24 if !ok { 25 return "", ErrLayerDoesNotExist 26 } 27 28 if layerGetter, ok := ls.driver.(Getter); ok { 29 return layerGetter.GetLayerPath(rl.cacheID) 30 } 31 32 path, err := ls.driver.Get(rl.cacheID, "") 33 if err != nil { 34 return "", err 35 } 36 37 if err := ls.driver.Put(rl.cacheID); err != nil { 38 return "", err 39 } 40 41 return path.Path(), nil 42 } 43 44 func (ls *layerStore) mountID(name string) string { 45 // windows has issues if container ID doesn't match mount ID 46 return name 47 }