Skip to content

Commit ac361f7

Browse files
committed
move CrashesIsEmpty function to the config package and rename it
1 parent 2ce9a06 commit ac361f7

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

config/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ func GetLogsDir() *paths.Path {
5151
return logsDir
5252
}
5353

54+
// LogsIsEmpty checks if the folder containing crash-reports is empty
55+
func LogsIsEmpty() bool {
56+
return GetLogsDir().NotExist() // if the logs directory is empty we assume there are no crashreports
57+
}
58+
5459
// GetDefaultConfigDir returns the full path to the default Arduino Create Agent configuration directory.
5560
func GetDefaultConfigDir() *paths.Path {
5661
// UserConfigDir returns the default root directory to use

systray/systray_real.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (s *Systray) start() {
6060

6161
// Remove crash-reports
6262
mRmCrashes := systray.AddMenuItem("Remove crash reports", "")
63-
s.updateMenuItem(mRmCrashes, s.CrashesIsEmpty())
63+
s.updateMenuItem(mRmCrashes, config.LogsIsEmpty())
6464

6565
// Add pause/quit
6666
mPause := systray.AddMenuItem("Pause Agent", "")
@@ -82,7 +82,7 @@ func (s *Systray) start() {
8282
_ = open.Start(s.currentConfigFilePath.String())
8383
case <-mRmCrashes.ClickedCh:
8484
s.RemoveCrashes()
85-
s.updateMenuItem(mRmCrashes, s.CrashesIsEmpty())
85+
s.updateMenuItem(mRmCrashes, config.LogsIsEmpty())
8686
case <-mPause.ClickedCh:
8787
s.Pause()
8888
case <-mQuit.ClickedCh:
@@ -101,12 +101,6 @@ func (s *Systray) updateMenuItem(item *systray.MenuItem, disable bool) {
101101
}
102102
}
103103

104-
// CrashesIsEmpty checks if the folder containing crash-reports is empty
105-
func (s *Systray) CrashesIsEmpty() bool {
106-
logsDir := config.GetLogsDir()
107-
return logsDir.NotExist() // if the logs directory is empty we assume there are no crashreports
108-
}
109-
110104
// RemoveCrashes removes the crash-reports from `logs` folder
111105
func (s *Systray) RemoveCrashes() {
112106
logsDir := config.GetLogsDir()

0 commit comments

Comments
 (0)