File: util.go

package info (click to toggle)
docker-registry 2.7.1%2Bds2-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, bullseye-backports
  • size: 3,004 kB
  • sloc: sh: 331; makefile: 78
file content (22 lines) | stat: -rw-r--r-- 475 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
}