mirror of
https://github.com/genuinetools/reg.git
synced 2024-08-21 14:20:23 -04:00
23 lines
475 B
Go
23 lines
475 B
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/docker/distribution/registry/storage/driver"
|
|
)
|
|
|
|
// Exists provides a utility method to test whether or not a path exists in
|
|
// the given driver.
|
|
func exists(ctx context.Context, drv driver.StorageDriver, path string) (bool, error) {
|
|
if _, err := drv.Stat(ctx, path); err != nil {
|
|
switch err := err.(type) {
|
|
case driver.PathNotFoundError:
|
|
return false, nil
|
|
default:
|
|
return false, err
|
|
}
|
|
}
|
|
|
|
return true, nil
|
|
}
|