MCPcopy
hub / github.com/jesseduffield/lazygit / startBackgroundRoutines

Method startBackgroundRoutines

pkg/gui/background.go:29–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27}
28
29func (self *BackgroundRoutineMgr) startBackgroundRoutines() {
30 userConfig := self.gui.UserConfig()
31
32 if userConfig.Git.AutoFetch {
33 fetchInterval := userConfig.Refresher.FetchInterval
34 if fetchInterval > 0 {
35 go utils.Safe(self.startBackgroundFetch)
36 } else {
37 self.gui.c.Log.Errorf(
38 "Value of config option 'refresher.fetchInterval' (%d) is invalid, disabling auto-fetch",
39 fetchInterval)
40 }
41 }
42
43 if userConfig.Git.AutoRefresh {
44 refreshInterval := userConfig.Refresher.RefreshInterval
45 if refreshInterval > 0 {
46 go utils.Safe(self.startBackgroundFilesRefresh)
47 } else {
48 self.gui.c.Log.Errorf(
49 "Value of config option 'refresher.refreshInterval' (%d) is invalid, disabling auto-refresh",
50 refreshInterval)
51 }
52 }
53
54 if self.gui.Config.GetDebug() {
55 self.goEvery(time.Second*time.Duration(10), self.gui.stopChan, func(_ bool) error {
56 formatBytes := func(b uint64) string {
57 const unit = 1000
58 if b < unit {
59 return fmt.Sprintf("%d B", b)
60 }
61 div, exp := uint64(unit), 0
62 for n := b / unit; n >= unit; n /= unit {
63 div *= unit
64 exp++
65 }
66 return fmt.Sprintf("%.1f %cB",
67 float64(b)/float64(div), "kMGTPE"[exp])
68 }
69
70 m := runtime.MemStats{}
71 runtime.ReadMemStats(&m)
72 self.gui.c.Log.Infof("Heap memory in use: %s", formatBytes(m.HeapAlloc))
73 return nil
74 })
75 }
76}
77
78func (self *BackgroundRoutineMgr) startBackgroundFetch() {
79 self.gui.waitForIntro.Wait()

Callers 1

RunMethod · 0.80

Calls 6

goEveryMethod · 0.95
SafeFunction · 0.92
UserConfigMethod · 0.80
ErrorfMethod · 0.80
GetDebugMethod · 0.65
SprintfMethod · 0.65

Tested by

no test coverage detected