Skip to content

Commit b63def0

Browse files
fix CR: avoid mutating internal state
1 parent 00993b5 commit b63def0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arduino/builder/build_options_manager.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,16 @@ func (m *BuildOptionsManager) wipeBuildPath() error {
154154
return wipe()
155155
}
156156

157+
// Since we might apply a side effect we clone it
158+
currentOptions := m.currentOptions.Clone()
157159
// If SketchLocation path is different but filename is the same, consider it equal
158-
if filepath.Base(m.currentOptions.Get("sketchLocation")) == filepath.Base(prevOpts.Get("sketchLocation")) {
159-
m.currentOptions.Remove("sketchLocation")
160+
if filepath.Base(currentOptions.Get("sketchLocation")) == filepath.Base(prevOpts.Get("sketchLocation")) {
161+
currentOptions.Remove("sketchLocation")
160162
prevOpts.Remove("sketchLocation")
161163
}
162164

163165
// If options are not changed check if core has
164-
if m.currentOptions.Equals(prevOpts) {
166+
if currentOptions.Equals(prevOpts) {
165167
// check if any of the files contained in the core folders has changed
166168
// since the json was generated - like platform.txt or similar
167169
// if so, trigger a "safety" wipe

0 commit comments

Comments
 (0)