Code polish

This commit is contained in:
2024-09-18 13:56:36 +02:00
parent 9242da25c0
commit 559820ce39
2 changed files with 9 additions and 6 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@ folder_mail_notifier.pp
folder-mail-notifier
my-notifier.pp
my-notifier.te
folder-mail-notifier.exe

14
main.go
View File

@@ -45,35 +45,37 @@ func main() {
var err error
envvar, err = godotenv.Parse(strings.NewReader(env))
if err != nil {
Error.Fatalf("Error parsing .env file: %v", err)
Error.Printf("Error parsing .env file: %v", err)
return
}
edelay, ok := envvar["DELAY"]
if !ok {
Error.Fatalf("Error parsing DELAY variable: %v", err)
Error.Printf("Error parsing DELAY variable: %v", err)
return
}
delay, err := time.ParseDuration(edelay)
if err != nil {
Error.Fatalf("Error parsing DELAY variable: %v", err)
Error.Printf("Error parsing DELAY variable: %v", err)
log.Printf("DELAY is a duration string, a poassibly signed sequence of decimal numbers, each with optional fraction and a unit prefix\nSuch as '300ms', '-1.5h' or '2h45m'.\nValid time units are 'ns', 'us' (or 'µs'), 'ms', 's', 'm', 'wh'.")
return
}
log.Printf("Delay parsed as %v seconds", delay.Seconds())
root, ok := envvar["ROOT"]
if !ok {
Error.Fatalf("Error parsing ROOT variable: %v", err)
Error.Printf("Error parsing ROOT variable: %v", err)
return
}
stat, err := os.Stat(root)
if err != nil {
Error.Fatalf("Error getting stat for '%v': %v", root, err)
Error.Printf("Error getting stat for '%v': %v", root, err)
return
}
if !stat.IsDir() {
Error.Fatalf("Error '%v' is not a directory", root)
Error.Printf("Error '%v' is not a directory", root)
return
}