layer_windows.go 1.1 KB

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