Skip to content

Commit 8c5a8b2

Browse files
authored
Fixed wrong IDE bundle-detection result caching (#606)
1 parent f690123 commit 8c5a8b2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: configuration/configuration.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ func IsBundledInDesktopIDE() bool {
142142
executable, err := os.Executable()
143143
if err != nil {
144144
feedback.Errorf("Cannot get executable path: %v", err)
145-
return viper.GetBool("IDE.Bundled")
145+
return false
146146
}
147147

148148
executablePath, err := filepath.EvalSymlinks(executable)
149149
if err != nil {
150150
feedback.Errorf("Cannot get executable path: %v", err)
151-
return viper.GetBool("IDE.Bundled")
151+
return false
152152
}
153153

154154
ideDir := filepath.Dir(executablePath)
@@ -163,17 +163,20 @@ func IsBundledInDesktopIDE() bool {
163163
for _, test := range tests {
164164
if _, err := os.Stat(filepath.Join(ideDir, test)); err != nil {
165165
// the test folder doesn't exist or is not accessible
166-
return viper.GetBool("IDE.Bundled")
166+
return false
167167
}
168168
}
169169

170+
// the CLI is bundled in the Arduino IDE
171+
172+
// Persist IDE-related config settings
173+
viper.Set("IDE.Bundled", true)
174+
viper.Set("IDE.Directory", ideDir)
175+
170176
// Check whether this is a portable install
171177
if _, err := os.Stat(filepath.Join(ideDir, "portable")); err != nil {
172178
viper.Set("IDE.Portable", true)
173179
}
174180

175-
// Persist IDE-related config settings and return true
176-
viper.Set("IDE.Bundled", false)
177-
viper.Set("IDE.Directory", ideDir)
178181
return true
179182
}

0 commit comments

Comments
 (0)