Skip to content

Commit

Permalink
Merge pull request #150 from Notifiarr/unstable
Browse files Browse the repository at this point in the history
fix deluge service check bug, and other bugs.
  • Loading branch information
davidnewhall authored Dec 23, 2021
2 parents 558a9ea + fbf6986 commit f0e17ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
10 changes: 4 additions & 6 deletions pkg/client/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ var (

// forceWriteWithExit is called only when a user passes --write on the command line.
func (c *Client) forceWriteWithExit(fileName string) error {
if fileName == "-" {
fileName = c.Flags.ConfigFile
} else if fileName == "example" || fileName == "---" {
if fileName == "example" || fileName == "---" {
// Bubilding a default template.
fileName = c.Flags.ConfigFile
fileName = c.Flags.ConfigFile + ".new"
c.Config.LogFile = ""
c.Config.LogConfig.DebugLog = ""
c.Config.HTTPLog = ""
Expand All @@ -40,8 +38,8 @@ func (c *Client) forceWriteWithExit(fileName string) error {
}

f, err := c.Config.Write(fileName)
if err != nil { // f purposely shadowed.
return fmt.Errorf("writing config: %s: %w", f, err)
if err != nil {
return fmt.Errorf("writing config: %w", err)
}

c.Print("Wrote Config File:", f)
Expand Down
10 changes: 7 additions & 3 deletions pkg/configfile/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,17 @@ func (c *Config) Write(file string) (string, error) {
return "", fmt.Errorf("making config dir: %w", err)
}

f, err := os.Create(file)
if _, err = os.Stat(file); err == nil {
return "", fmt.Errorf("%w: %s", os.ErrExist, file)
}

newFile, err := os.Create(file)
if err != nil {
return "", fmt.Errorf("creating config file: %w", err)
}
defer f.Close()
defer newFile.Close()

if err := Template.Execute(f, c); err != nil {
if err := Template.Execute(newFile, c); err != nil {
return "", fmt.Errorf("writing config file: %w", err)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/plex/plex.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"

"golift.io/cnfg"
Expand Down Expand Up @@ -58,6 +59,8 @@ func (s *Server) Configured() bool {

// Validate checks input values and starts the cron interval if it's configured.
func (s *Server) Validate() { //nolint:cyclop
s.URL = strings.TrimRight(s.URL, "/")

if s.SeriesPC > maximumComplete {
s.SeriesPC = maximumComplete
} else if s.SeriesPC != 0 && s.SeriesPC < minimumComplete {
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (c *Config) collectDownloadApps(svcs []*Service) []*Service {
svcs = append(svcs, &Service{
Name: d.Name,
Type: CheckHTTP,
Value: d.Config.URL,
Value: strings.TrimSuffix(d.Config.URL, "/json"),
Expect: "200",
Timeout: cnfg.Duration{Duration: d.Timeout.Duration},
Interval: d.Interval,
Expand Down

0 comments on commit f0e17ce

Please sign in to comment.