Skip to content

Commit b97fce6

Browse files
committed
Use default user's cache dir instead of tmp for build cache
1 parent 425779d commit b97fce6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

commands/service_compile_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
func TestGenBuildPath(t *testing.T) {
27-
want := paths.TempDir().Join("arduino", "sketches", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
2827
srv := NewArduinoCoreServer().(*arduinoCoreServerImpl)
28+
want := srv.settings.GetBuildCachePath().Join("sketches", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
2929
act := srv.getDefaultSketchBuildPath(&sketch.Sketch{FullPath: paths.New("foo")}, nil)
3030
assert.True(t, act.EquivalentTo(want))
3131
assert.Equal(t, "ACBD18DB4CC2F85CEDEF654FCCC4A4D8", (&sketch.Sketch{FullPath: paths.New("foo")}).Hash())

internal/cli/configuration/configuration.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ func getDefaultUserDir() string {
103103

104104
// getDefaultBuildCacheDir returns the full path to the default build cache folder
105105
func getDefaultBuildCacheDir() string {
106-
return paths.TempDir().Join("arduino").String()
106+
var cacheDir *paths.Path
107+
if p, err := os.UserCacheDir(); err == nil {
108+
cacheDir = paths.New(p)
109+
} else {
110+
// fallback to /tmp
111+
cacheDir = paths.TempDir()
112+
}
113+
return cacheDir.Join("arduino").String()
107114
}
108115

109116
// FindConfigFlagsInArgsOrFallbackOnEnv returns the config file path using the

0 commit comments

Comments
 (0)