Skip to content

Commit

Permalink
Use default user's cache dir instead of tmp for build cache
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Aug 9, 2024
1 parent 425779d commit b97fce6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion commands/service_compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
)

func TestGenBuildPath(t *testing.T) {
want := paths.TempDir().Join("arduino", "sketches", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
srv := NewArduinoCoreServer().(*arduinoCoreServerImpl)
want := srv.settings.GetBuildCachePath().Join("sketches", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
act := srv.getDefaultSketchBuildPath(&sketch.Sketch{FullPath: paths.New("foo")}, nil)
assert.True(t, act.EquivalentTo(want))
assert.Equal(t, "ACBD18DB4CC2F85CEDEF654FCCC4A4D8", (&sketch.Sketch{FullPath: paths.New("foo")}).Hash())
Expand Down
9 changes: 8 additions & 1 deletion internal/cli/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ func getDefaultUserDir() string {

// getDefaultBuildCacheDir returns the full path to the default build cache folder
func getDefaultBuildCacheDir() string {
return paths.TempDir().Join("arduino").String()
var cacheDir *paths.Path
if p, err := os.UserCacheDir(); err == nil {
cacheDir = paths.New(p)
} else {
// fallback to /tmp
cacheDir = paths.TempDir()
}
return cacheDir.Join("arduino").String()
}

// FindConfigFlagsInArgsOrFallbackOnEnv returns the config file path using the
Expand Down

0 comments on commit b97fce6

Please sign in to comment.