Update snapshot mkdir to check for directory exist
When starting up a snapshot driver on subsequent runs, the mkdir call will return an exist error, this can be safely ignored. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
56972bf915
commit
63f01733b0
3 changed files with 7 additions and 3 deletions
|
@ -46,6 +46,10 @@ type snapshotter struct {
|
||||||
// device and root directory for snapshots and stores the metadata in
|
// device and root directory for snapshots and stores the metadata in
|
||||||
// a file in the provided root.
|
// a file in the provided root.
|
||||||
func NewSnapshotter(device, root string) (snapshot.Snapshotter, error) {
|
func NewSnapshotter(device, root string) (snapshot.Snapshotter, error) {
|
||||||
|
if err := os.MkdirAll(root, 0700); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
active = filepath.Join(root, "active")
|
active = filepath.Join(root, "active")
|
||||||
snapshots = filepath.Join(root, "snapshots")
|
snapshots = filepath.Join(root, "snapshots")
|
||||||
|
@ -55,7 +59,7 @@ func NewSnapshotter(device, root string) (snapshot.Snapshotter, error) {
|
||||||
active,
|
active,
|
||||||
snapshots,
|
snapshots,
|
||||||
} {
|
} {
|
||||||
if err := os.MkdirAll(path, 0755); err != nil {
|
if err := os.Mkdir(path, 0755); err != nil && !os.IsExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Mkdir(filepath.Join(root, "snapshots"), 0700); err != nil {
|
if err := os.Mkdir(filepath.Join(root, "snapshots"), 0700); err != nil && !os.IsExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(filepath.Join(root, "snapshots"), 0700); err != nil {
|
if err := os.Mkdir(filepath.Join(root, "snapshots"), 0700); err != nil && !os.IsExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue