Skip to content

Commit

Permalink
fixed some backup path issues and reload issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer committed Apr 2, 2024
1 parent 57097ff commit 3d736fe
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var cli struct {
Configfiles []string `arg name:"conf" help:"Path to the configfile." default:"conf.yml"`
Version bool `flag name:"version" help:"Show version."`
Dry bool `flag name:"dryrun" help:"Make a dry-run."`
Debug bool `flag name:"debug" help:"Output debug messages"`
Quiet bool `flag name:"quiet" help:"Output only warnings, errors, and fatal messages to stderr log output"`
Silent bool `flag name:"silent" help:"Suppress all stderr log output"`
}
Expand Down Expand Up @@ -154,17 +155,16 @@ func backup(repos []types.Repo, conf *types.Conf) {
log.Warn().Str("stage", "backup").Msg("No destinations configured!")
}

for i, d := range conf.Destination.Local {
for _, d := range conf.Destination.Local {
if !checkedpath {
path, err := filepath.Abs(d.Path)
_, err := filepath.Abs(d.Path)
if err != nil {
log.Fatal().
Str("stage", "locally").
Str("path", d.Path).
Msg(err.Error())
}

conf.Destination.Local[i].Path = path
checkedpath = true
}

Expand Down Expand Up @@ -573,6 +573,7 @@ func playsForever(c *cron.Cron, conffiles []string, confs []*types.Conf) bool {

if !cmp.Equal(confs, checkconfigs) {
log.Info().Msg("config changed")
log.Debug().Msg(cmp.Diff(confs, checkconfigs))
for _, entry := range c.Entries() {
c.Remove(entry.ID)
}
Expand Down Expand Up @@ -608,6 +609,10 @@ func main() {
zerolog.SetGlobalLevel(zerolog.WarnLevel)
}

if cli.Debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

if cli.Silent {
zerolog.SetGlobalLevel(zerolog.Disabled)
}
Expand All @@ -622,11 +627,15 @@ func main() {
for {
reload := false
confs := []*types.Conf{}
for _, f := range cli.Configfiles {
for i, f := range cli.Configfiles {
log.Info().Str("file", f).
Msgf("Reading %s", types.Green(f))

confs = append(confs, readConfigFile(f)...)
absf, err := filepath.Abs(f)
if err != nil {
log.Panic().Err(err).Msgf("there is an issue with %s", f)
}
cli.Configfiles[i] = absf
confs = append(confs, readConfigFile(absf)...)
}

logConf := confs[0].Log
Expand Down

0 comments on commit 3d736fe

Please sign in to comment.