crash fix for offline boxes

This commit is contained in:
shoopea 2023-07-31 10:34:14 +02:00
parent 138786855f
commit 88220d47e6
2 changed files with 19 additions and 17 deletions

28
app.go
View File

@ -172,20 +172,22 @@ func (a *App) Cleanup(now time.Time) error {
}
}
for _, dest := range a.destinations {
dest = dest.Append("/" + src.Box() + "/" + src.Path())
for _, s := range cfg.box[dest.Box()].zfs.filesystems[dest.Path()].snapshots {
if !s.Valid() {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
return err
}
} else if expired, err := s.Expired(now); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": dest.Box(), "snapshot": s.String(), "call": "Expired", "error": err}).Errorf("")
return err
} else if expired {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
if cfg.box[dest.Box()].online {
dest = dest.Append("/" + src.Box() + "/" + src.Path())
for _, s := range cfg.box[dest.Box()].zfs.filesystems[dest.Path()].snapshots {
if !s.Valid() {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
return err
}
} else if expired, err := s.Expired(now); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": dest.Box(), "snapshot": s.String(), "call": "Expired", "error": err}).Errorf("")
return err
} else if expired {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
return err
}
}
}
}

View File

@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "2afd699"
var githash = "1387868"
var branch = "v2"
var buildstamp = "2023-07-31_08:29:23"
var commits = "68"
var version = "2afd699-b68 - 2023-07-31_08:29:23"
var buildstamp = "2023-07-31_08:33:33"
var commits = "69"
var version = "1387868-b69 - 2023-07-31_08:33:33"