Moving os.MkdirAll() inside atomic for auto parent directory creates

This commit is contained in:
Harshavardhana
2015-07-07 12:35:50 -07:00
parent 5fc377ae57
commit 11b893804c
2 changed files with 7 additions and 8 deletions

View File

@@ -153,13 +153,7 @@ func (disk Disk) CreateFile(filename string) (*atomic.File, error) {
return nil, iodine.New(InvalidArgument{}, nil)
}
filePath := filepath.Join(disk.path, filename)
// Create directories if they don't exist
if err := os.MkdirAll(filepath.Dir(filePath), 0700); err != nil {
return nil, iodine.New(err, nil)
}
f, err := atomic.FileCreate(filePath)
f, err := atomic.FileCreate(filepath.Join(disk.path, filename))
if err != nil {
return nil, iodine.New(err, nil)
}