Compare commits

...

2 Commits

Author SHA1 Message Date
Boris Bera
a7679248f0
Merge 5ed1af31e0 into 41e4e4a5f3 2024-10-17 10:11:51 -04:00
Boris Bera
41e4e4a5f3
fix(cron): crash when errors are encountered during a backup (#403) 2024-10-17 13:49:45 +02:00
2 changed files with 16 additions and 2 deletions

View File

@ -1,12 +1,22 @@
package internal
import (
"errors"
"fmt"
)
func RunCron() error {
c := GetConfig()
var errs []error
for name, l := range c.Locations {
l.name = name
if err := l.RunCron(); err != nil {
return err
errs = append(errs, err)
}
}
if len(errs) > 0 {
return fmt.Errorf("Encountered errors during cron process:\n%w", errors.Join(errs...))
}
return nil
}

View File

@ -1,6 +1,7 @@
package internal
import (
"errors"
"fmt"
"io/ioutil"
"os"
@ -454,7 +455,10 @@ func (l Location) RunCron() error {
now := time.Now()
if now.After(next) {
lock.SetCron(l.name, now.Unix())
l.Backup(true, "")
errs := l.Backup(true, "")
if len(errs) > 0 {
return fmt.Errorf("Failed to backup location \"%s\":\n%w", l.name, errors.Join(errs...))
}
} else {
if !flags.CRON_LEAN {
colors.Body.Printf("Skipping \"%s\", not due yet.\n", l.name)