2015-11-18 17:15:00 -05:00
|
|
|
package layer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2015-12-16 15:32:16 -05:00
|
|
|
"github.com/docker/docker/daemon/graphdriver"
|
2015-11-18 17:15:00 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2015-12-16 17:13:50 -05:00
|
|
|
func (ls *layerStore) mountID(name string) string {
|
|
|
|
// windows has issues if container ID doesn't match mount ID
|
|
|
|
return name
|
|
|
|
}
|
2015-12-16 15:32:16 -05:00
|
|
|
|
|
|
|
func (ls *layerStore) GraphDriver() graphdriver.Driver {
|
|
|
|
return ls.driver
|
|
|
|
}
|