fix crash for new app with no dest path existing

This commit is contained in:
shoopea 2023-07-01 22:34:04 +02:00
parent e07c1c4f3f
commit 24a5e6676f
2 changed files with 11 additions and 9 deletions

4
app.go
View File

@ -230,7 +230,8 @@ func (a *App) SanityCheck() error {
onlineDestinations++ onlineDestinations++
for _, src := range a.sources { for _, src := range a.sources {
dest2 := dest.Append("/" + src.Box() + "/" + src.Path()) dest2 := dest.Append("/" + src.Box() + "/" + src.Path())
for _, s := range b.zfs.filesystems[dest2.Path()].snapshots { if fs, ok := b.zfs.filesystems[dest2.Path()]; ok {
for _, s := range fs.snapshots {
if !s.Valid() { if !s.Valid() {
if err := s.Delete(); err != nil { if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("") log.WithFields(log.Fields{"app": a.name, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
@ -241,6 +242,7 @@ func (a *App) SanityCheck() error {
} }
} }
} }
}
if onlineDestinations == 0 { if onlineDestinations == 0 {
err := errors.New("no destination box online") err := errors.New("no destination box online")
log.WithFields(log.Fields{"app": a.name, "error": err}).Errorf("") log.WithFields(log.Fields{"app": a.name, "error": err}).Errorf("")

View File

@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "db05789" var githash = "e07c1c4"
var branch = "v2" var branch = "v2"
var buildstamp = "2023-07-01_12:10:14" var buildstamp = "2023-07-01_20:33:58"
var commits = "64" var commits = "65"
var version = "db05789-b64 - 2023-07-01_12:10:14" var version = "e07c1c4-b65 - 2023-07-01_20:33:58"