config: Add option 'git.autoRefresh' to en-/disable auto-refresh

Adds a new 'autoRefresh' option to the 'git' config section that allows user to
disable auto-refresh (defaults to on). If auto-refresh is enabled, the
refreshInterval is now checked before starting the timer to prevent crashes when
it is non-positive.

Fixes #1417
This commit is contained in:
Moritz Haase 2022-03-26 18:10:58 +01:00 committed by Jesse Duffield
parent 51baa8c17d
commit 240483953f
3 changed files with 14 additions and 2 deletions

View file

@ -587,7 +587,16 @@ func (gui *Gui) Run(filterPath string) error {
go utils.Safe(gui.startBackgroundFetch)
}
gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules)
if userConfig.Git.AutoRefresh {
refreshInterval := userConfig.Refresher.RefreshInterval
if refreshInterval > 0 {
gui.goEvery(time.Second*time.Duration(refreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules)
} else {
gui.c.Log.Errorf(
"Value of config option 'refresher.refreshInterval' (%d) is invalid, disabling auto-refresh",
refreshInterval)
}
}
gui.c.Log.Info("starting main loop")