github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/layer/layer_windows.go (about)

     1  package layer // import "github.com/demonoid81/moby/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 unmountable 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  	path, err := ls.driver.Get(rl.cacheID, "")
    32  	if err != nil {
    33  		return "", err
    34  	}
    35  
    36  	if err := ls.driver.Put(rl.cacheID); err != nil {
    37  		return "", err
    38  	}
    39  
    40  	return path.Path(), nil
    41  }
    42  
    43  func (ls *layerStore) mountID(name string) string {
    44  	// windows has issues if container ID doesn't match mount ID
    45  	return name
    46  }