pkg/gui: Fix crash if auto-fetch interval is non-positive

Check whether the auto-fetch interval configured is actually positive before
starting the background fetcher. If it is not, an error is logged. Also improve
the config option documentation a bit to make it easier to understand how to
disable auto-fetch.
This commit is contained in:
Moritz Haase 2022-03-26 18:24:36 +01:00 committed by Jesse Duffield
parent 240483953f
commit 4abd80e2c4
2 changed files with 11 additions and 3 deletions

View file

@ -583,8 +583,16 @@ func (gui *Gui) Run(filterPath string) error {
}
gui.waitForIntro.Add(1)
if gui.c.UserConfig.Git.AutoFetch {
go utils.Safe(gui.startBackgroundFetch)
if userConfig.Git.AutoFetch {
fetchInterval := userConfig.Refresher.FetchInterval
if fetchInterval > 0 {
go utils.Safe(gui.startBackgroundFetch)
} else {
gui.c.Log.Errorf(
"Value of config option 'refresher.fetchInterval' (%d) is invalid, disabling auto-fetch",
fetchInterval)
}
}
if userConfig.Git.AutoRefresh {