Fix launch problem when directories doesn't exist
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
15be0cf465
commit
3c14a3685c
13
main.go
13
main.go
@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
var mux = http.NewServeMux()
|
||||
@ -30,7 +31,7 @@ func main() {
|
||||
if htpasswd, err = NewHtpasswd(*htpasswd_file); htpasswd == nil {
|
||||
log.Fatal("Unable to parse htpasswd:", err)
|
||||
}
|
||||
} else if *nextImgDir == "./images/next/" {
|
||||
} else if *nextImgDir == "next/" {
|
||||
log.Println("Disable admin interface, images will be published without moderation")
|
||||
nextImgDir = publishedImgDir
|
||||
}
|
||||
@ -57,6 +58,16 @@ func main() {
|
||||
var storage_backend FileBackend
|
||||
if backend == nil || *backend == "local" {
|
||||
storage_backend = &LocalFileBackend{*baseDir}
|
||||
if _, err := os.Stat(path.Join(*baseDir, *publishedImgDir)); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(path.Join(*baseDir, *publishedImgDir), 0755); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(path.Join(*baseDir, *nextImgDir)); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(path.Join(*baseDir, *nextImgDir), 0755); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
} else if *backend == "s3" {
|
||||
storage_backend = &S3FileBackend{s3_endpoint, s3_region, s3_bucket, s3_access_key, s3_secret_key, s3_path_style, *baseDir}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user