Skip to content

Commit

Permalink
fix CR: avoid mutating internal state
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 15, 2023
1 parent 00993b5 commit b63def0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arduino/builder/build_options_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,16 @@ func (m *BuildOptionsManager) wipeBuildPath() error {
return wipe()
}

// Since we might apply a side effect we clone it
currentOptions := m.currentOptions.Clone()
// If SketchLocation path is different but filename is the same, consider it equal
if filepath.Base(m.currentOptions.Get("sketchLocation")) == filepath.Base(prevOpts.Get("sketchLocation")) {
m.currentOptions.Remove("sketchLocation")
if filepath.Base(currentOptions.Get("sketchLocation")) == filepath.Base(prevOpts.Get("sketchLocation")) {
currentOptions.Remove("sketchLocation")
prevOpts.Remove("sketchLocation")
}

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

0 comments on commit b63def0

Please sign in to comment.