github.com/mika/distribution@v2.2.2-0.20160108133430-a75790e3d8e0+incompatible/registry/storage/util.go (about) 1 package storage 2 3 import ( 4 "github.com/docker/distribution/context" 5 "github.com/docker/distribution/registry/storage/driver" 6 ) 7 8 // Exists provides a utility method to test whether or not a path exists in 9 // the given driver. 10 func exists(ctx context.Context, drv driver.StorageDriver, path string) (bool, error) { 11 if _, err := drv.Stat(ctx, path); err != nil { 12 switch err := err.(type) { 13 case driver.PathNotFoundError: 14 return false, nil 15 default: 16 return false, err 17 } 18 } 19 20 return true, nil 21 }