Merge pull request #698 from dmcgowan/snapshot-mkdir-exist
Update snapshot mkdir to check for directory exist
This commit is contained in:
commit
0a484cc5dc
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
|
||||
// a file in the provided root.
|
||||
func NewSnapshotter(device, root string) (snapshot.Snapshotter, error) {
|
||||
if err := os.MkdirAll(root, 0700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
active = filepath.Join(root, "active")
|
||||
snapshots = filepath.Join(root, "snapshots")
|
||||
|
@ -55,7 +59,7 @@ func NewSnapshotter(device, root string) (snapshot.Snapshotter, error) {
|
|||
active,
|
||||
snapshots,
|
||||
} {
|
||||
if err := os.MkdirAll(path, 0755); err != nil {
|
||||
if err := os.Mkdir(path, 0755); err != nil && !os.IsExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
|
|||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
|
|||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue