mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
02ed83aee9
Signed-off-by: John Howard <jhoward@microsoft.com>
42 lines
785 B
Go
42 lines
785 B
Go
package layer
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/docker/docker/daemon/graphdriver"
|
|
)
|
|
|
|
// GetLayerPath returns the path to a layer
|
|
func GetLayerPath(s Store, layer ChainID) (string, error) {
|
|
ls, ok := s.(*layerStore)
|
|
if !ok {
|
|
return "", errors.New("unsupported layer store")
|
|
}
|
|
ls.layerL.Lock()
|
|
defer ls.layerL.Unlock()
|
|
|
|
rl, ok := ls.layerMap[layer]
|
|
if !ok {
|
|
return "", ErrLayerDoesNotExist
|
|
}
|
|
|
|
path, err := ls.driver.Get(rl.cacheID, "")
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
if err := ls.driver.Put(rl.cacheID); err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return path, nil
|
|
}
|
|
|
|
func (ls *layerStore) mountID(name string) string {
|
|
// windows has issues if container ID doesn't match mount ID
|
|
return name
|
|
}
|
|
|
|
func (ls *layerStore) GraphDriver() graphdriver.Driver {
|
|
return ls.driver
|
|
}
|