Filestore - create path if it doesn't exist

This commit is contained in:
Soam Vasani
2016-11-02 16:06:27 -07:00
parent 91eb0ca3cd
commit b1587551d5
+13
View File
@@ -52,6 +52,19 @@ type (
)
func MakeFileStore(path string) *FileStore {
// create directory if necessary
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(path, os.ModeDir|0700)
if err != nil {
log.Printf("Failed to create directory %v", path)
return nil
}
log.Printf("Created directory %v", path)
}
}
fileStore := &FileStore{
root: path,
requestChannel: make(chan fileStoreRequest),