Skip to content

Commit 298e69f

Browse files
author
Luca Bianconi
committed
feat: new cached files naming
1 parent 7082f17 commit 298e69f

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

Diff for: arduino/sketch/sketch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func GenBuildPath(sketchPath *paths.Path) *paths.Path {
303303
md5SumBytes := md5.Sum([]byte(path))
304304
md5Sum := strings.ToUpper(hex.EncodeToString(md5SumBytes[:]))
305305

306-
return getSketchesCacheDir().Join("sketch-" + md5Sum)
306+
return getSketchesCacheDir().Join(md5Sum)
307307
}
308308

309309
func getSketchesCacheDir() *paths.Path {

Diff for: arduino/sketch/sketch_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@ func TestNewSketchFolderSymlink(t *testing.T) {
286286
}
287287

288288
func TestGenBuildPath(t *testing.T) {
289-
want := paths.TempDir().Join("arduino", "sketches", "sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
289+
want := paths.TempDir().Join("arduino", "sketches", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
290290
assert.True(t, GenBuildPath(paths.New("foo")).EquivalentTo(want))
291291

292-
want = paths.TempDir().Join("arduino", "sketches", "sketch-D41D8CD98F00B204E9800998ECF8427E")
292+
want = paths.TempDir().Join("arduino", "sketches", "D41D8CD98F00B204E9800998ECF8427E")
293293
assert.True(t, GenBuildPath(nil).EquivalentTo(want))
294294
}
295295

Diff for: buildcache/build_cache_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import (
2424
)
2525

2626
func Test_UpdateLastUsedFileNotExisting(t *testing.T) {
27-
testBuildDir := paths.New(t.TempDir(), "sketches", "sketch-xxx")
27+
testBuildDir := paths.New(t.TempDir(), "sketches", "xxx")
2828
require.NoError(t, testBuildDir.MkdirAll())
2929
timeBeforeUpdating := time.Unix(0, 0)
3030
requireCorrectUpdate(t, testBuildDir, timeBeforeUpdating)
3131
}
3232

3333
func Test_UpdateLastUsedFileExisting(t *testing.T) {
34-
testBuildDir := paths.New(t.TempDir(), "sketches", "sketch-xxx")
34+
testBuildDir := paths.New(t.TempDir(), "sketches", "xxx")
3535
require.NoError(t, testBuildDir.MkdirAll())
3636

3737
// create the file

Diff for: internal/integrationtest/compile_1/compile_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func compileWithSimpleSketchCustomEnv(t *testing.T, env *integrationtest.Environ
172172
md5 := md5.Sum(([]byte(sketchPath.String())))
173173
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
174174
require.NotEmpty(t, sketchPathMd5)
175-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
175+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
176176
require.FileExists(t, buildDir.Join(sketchName+".ino.eep").String())
177177
require.FileExists(t, buildDir.Join(sketchName+".ino.elf").String())
178178
require.FileExists(t, buildDir.Join(sketchName+".ino.hex").String())
@@ -406,7 +406,7 @@ func compileWithOutputDirFlag(t *testing.T, env *integrationtest.Environment, cl
406406
md5 := md5.Sum(([]byte(sketchPath.String())))
407407
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
408408
require.NotEmpty(t, sketchPathMd5)
409-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
409+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
410410
require.FileExists(t, buildDir.Join(sketchName+".ino.eep").String())
411411
require.FileExists(t, buildDir.Join(sketchName+".ino.elf").String())
412412
require.FileExists(t, buildDir.Join(sketchName+".ino.hex").String())
@@ -473,7 +473,7 @@ func compileWithCustomBuildPath(t *testing.T, env *integrationtest.Environment,
473473
md5 := md5.Sum(([]byte(sketchPath.String())))
474474
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
475475
require.NotEmpty(t, sketchPathMd5)
476-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
476+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
477477
require.NoFileExists(t, buildDir.Join(sketchName+".ino.eep").String())
478478
require.NoFileExists(t, buildDir.Join(sketchName+".ino.elf").String())
479479
require.NoFileExists(t, buildDir.Join(sketchName+".ino.hex").String())
@@ -1007,7 +1007,7 @@ func compileWithInvalidBuildOptionJson(t *testing.T, env *integrationtest.Enviro
10071007
md5 := md5.Sum(([]byte(sketchPath.String())))
10081008
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
10091009
require.NotEmpty(t, sketchPathMd5)
1010-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
1010+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
10111011

10121012
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
10131013
require.NoError(t, err)

Diff for: internal/integrationtest/compile_2/compile_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func recompileWithDifferentLibrary(t *testing.T, env *integrationtest.Environmen
145145
md5 := md5.Sum(([]byte(sketchPath.String())))
146146
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
147147
require.NotEmpty(t, sketchPathMd5)
148-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
148+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
149149

150150
// Compile sketch using library not managed by CLI
151151
stdout, _, err := cli.Run("compile", "-b", fqbn, "--library", manuallyInstalledLibPath.String(), sketchPath.String(), "-v")

Diff for: internal/integrationtest/core/core_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func TestCoreInstallEsp32(t *testing.T) {
253253
md5 := md5.Sum(([]byte(sketchPath.String())))
254254
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
255255
require.NotEmpty(t, sketchPathMd5)
256-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
256+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
257257
require.FileExists(t, buildDir.Join(sketchName+".ino.partitions.bin").String())
258258
}
259259

Diff for: internal/integrationtest/upload_mock/upload_mock_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ func TestUploadSketch(t *testing.T) {
697697
func generateBuildDir(sketchPath *paths.Path, t *testing.T) *paths.Path {
698698
md5 := md5.Sum(([]byte(sketchPath.String())))
699699
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
700-
buildDir := paths.TempDir().Join("arduino", "sketches", "sketch-"+sketchPathMd5)
700+
buildDir := paths.TempDir().Join("arduino", "sketches", sketchPathMd5)
701701
require.NoError(t, buildDir.MkdirAll())
702702
require.NoError(t, buildDir.ToAbs())
703703
return buildDir

Diff for: legacy/builder/phases/core_builder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ func GetCachedCoreArchiveDirName(fqbn string, optimizationFlags string, coreFold
149149
coreFolder = absCoreFolder
150150
} // silently continue if absolute path can't be detected
151151
hash := utils.MD5Sum([]byte(coreFolder.String() + optimizationFlags))
152-
realName := "core_" + fqbnToUnderscore + "_" + hash
152+
realName := fqbnToUnderscore + "_" + hash
153153
if len(realName) > 100 {
154154
// avoid really long names, simply hash the final part
155-
realName = "core_" + utils.MD5Sum([]byte(fqbnToUnderscore+"_"+hash))
155+
realName = utils.MD5Sum([]byte(fqbnToUnderscore + "_" + hash))
156156
}
157157
return realName
158158
}

0 commit comments

Comments
 (0)