Create image folder if it does not exist
This commit is contained in:
@@ -96,3 +96,14 @@ func computePathFromName(ac *appcontext.AppContext, filename string) string {
|
||||
func GetWsLinkPrefix() string {
|
||||
return "/static/bookcover/"
|
||||
}
|
||||
|
||||
func CreateFolderIfMissing(dir string) error {
|
||||
_, openFileErr := os.Open(dir)
|
||||
if os.IsNotExist(openFileErr) {
|
||||
return os.MkdirAll(dir, 0755)
|
||||
} else if openFileErr != nil {
|
||||
return openFileErr
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user