summaryrefslogtreecommitdiff
path: root/app/app.go
diff options
context:
space:
mode:
authorHeinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>2023-01-16 11:29:55 +0000
committerJames Mills <james@mills.io>2023-01-16 11:29:55 +0000
commit9952cc533ac093a9b8acf964642e42ae8962f768 (patch)
tree60905f2bf1cb06490aaa34569e9b10354f48e4dc /app/app.go
parentdc5cceec3704317f71b078d145ca1ec1d801da72 (diff)
improve logging at startup (#51)
This bit me hard in the begining. While I was trying to figure out why tube I didn't show any files, it was silently creating directories all over the place. 😆 Reviewed-on: https://git.mills.io/prologic/tube/pulls/51 Co-authored-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> Co-committed-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
Diffstat (limited to 'app/app.go')
-rw-r--r--app/app.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/app.go b/app/app.go
index ae9244c..f2d729a 100644
--- a/app/app.go
+++ b/app/app.go
@@ -161,11 +161,15 @@ func (a *App) Run() error {
}
a.Watcher.Add(p.Path)
}
- if err := os.MkdirAll(a.Config.Server.UploadPath, 0o755); err != nil {
- return fmt.Errorf(
- "error creating upload path %s: %w",
- a.Config.Server.UploadPath, err,
- )
+ if _, err := os.Stat(a.Config.Server.UploadPath) ; err != nil && os.IsNotExist(err) {
+ log.Warn(
+ fmt.Sprintf("app: upload path '%s' does not exist. Creating it now.",
+ a.Config.Server.UploadPath))
+ if err := os.MkdirAll(a.Config.Server.UploadPath, 0o755); err != nil {
+ return fmt.Errorf(
+ "error creating upload path %s: %w",
+ a.Config.Server.UploadPath, err)
+ }
}
buildFeed(a)
go startWatcher(a)