Skip to content

Commit

Permalink
Merge pull request #149 from Notifiarr/dnw_bug
Browse files Browse the repository at this point in the history
fix bug causing crash in snapshot
  • Loading branch information
davidnewhall authored Dec 22, 2021
2 parents 42d7b1e + 65d5c6b commit 558a9ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"bufio"
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"sync"
Expand Down Expand Up @@ -157,7 +158,7 @@ func (c *Config) getSnapshot(ctx context.Context, s *Snapshot) ([]error, []error
errs = append(errs, err...)
}

if syn, err := GetSynology(c.Uptime); err != nil {
if syn, err := GetSynology(c.Uptime); err != nil && !errors.Is(err, ErrNotSynology) {
errs = append(errs, err)
} else if syn != nil {
syn.SetInfo(s.System.InfoStat)
Expand Down
4 changes: 3 additions & 1 deletion pkg/snapshot/synology.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/shirou/gopsutil/v3/host"
)

var ErrNotSynology = fmt.Errorf("the running host is not a Synology")

// Synology is the data we care about from the config file.
type Synology struct {
Build string `json:"last_admin_login_build"` // 254263
Expand All @@ -30,7 +32,7 @@ type Synology struct {
// GetSynology checks if the app is running on a Synology, and gets system info.
func GetSynology(run bool) (*Synology, error) { //nolint:cyclop
if !run || !mnd.IsSynology {
return &Synology{}, nil
return nil, ErrNotSynology
}

file, err := os.Open(mnd.Synology)
Expand Down

0 comments on commit 558a9ea

Please sign in to comment.