remove sources invalid snapshots

This commit is contained in:
shoopea
2023-07-01 00:15:31 +02:00
parent c372d43104
commit db05789cfe
2 changed files with 10 additions and 5 deletions

7
app.go
View File

@@ -156,7 +156,12 @@ func (a *App) Cleanup(now time.Time) error {
for _, src := range a.sources {
for _, s := range cfg.box[src.Box()].zfs.filesystems[src.Path()].snapshots {
if expired, err := s.Expired(now); err != nil {
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": src.Box(), "snapshot": s.String(), "call": "Expired", "error": err}).Errorf("")
return err
} else if expired {