Skip to content

Commit

Permalink
fix running outside of config dir (#6)
Browse files Browse the repository at this point in the history
* skip archival without config

* use full paths to configs
  • Loading branch information
graphaelli committed Jan 10, 2020
1 parent 5ab371c commit d536644
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ var (
)

func doRun(zat *Config, params runParams) {
if zat == nil {
// no logger to log with
return
}
zat.logger.Print("starting archive tool")
if !zat.googleClient.HasCreds() {
zat.logger.Println("no Google creds")
Expand Down Expand Up @@ -471,15 +475,15 @@ func main() {
googleClient, err := google.NewClientFromFile(
logger,
path.Join(*cfgDir, cmd.GoogleConfigPath),
google.NewCredentialsManager(cmd.GoogleCredsPath).ClientOption,
google.NewCredentialsManager(path.Join(*cfgDir, cmd.GoogleCredsPath)).ClientOption,
)
if err != nil {
logger.Fatal(err)
}
zoomClient, err := zoom.NewClientFromFile(
logger,
path.Join(*cfgDir, cmd.ZoomConfigPath),
zoom.NewCredentialsManager(cmd.ZoomCredsPath).ClientOption,
zoom.NewCredentialsManager(path.Join(*cfgDir, cmd.ZoomCredsPath)).ClientOption,
)
if err != nil {
logger.Fatal(err)
Expand All @@ -490,8 +494,9 @@ func main() {
since: *since,
}

zat, err := NewConfigFromFile(logger, cmd.ZatConfigPath, googleClient, zoomClient)
zat, err := NewConfigFromFile(logger, path.Join(*cfgDir, cmd.ZatConfigPath), googleClient, zoomClient)
if err != nil {
// ok to continue without config, just can't do archival
logger.Println("failed to load config", err)
}

Expand All @@ -511,11 +516,14 @@ func main() {
}()
}

wg.Add(1)
go func() {
doRun(zat, rp)
wg.Done()
}()
if zat != nil {
// already logged that config is loaded, just skip the run
wg.Add(1)
go func() {
doRun(zat, rp)
wg.Done()
}()
}

wg.Wait()
}

0 comments on commit d536644

Please sign in to comment.