mirror of
https://github.com/burrowers/garble.git
synced 2026-04-22 15:47:04 +08:00
do not create ./build in cwd when cache init is skipped (#1035)
sharedCache is allocated before goVersionOK runs, but CacheDir is only set once the version check passes. The trim defer in mainErr only checked sharedCache != nil, so on the too-new-version path openCache joined an empty CacheDir with "build" and created the directory in CWD. Fixes #995.
This commit is contained in:
@@ -261,7 +261,7 @@ func mainErr(args []string) error {
|
||||
fmt.Fprintf(os.Stderr, "could not clean up GARBLE_SHARED: %v\n", err)
|
||||
}
|
||||
// skip the trim if we didn't even start a build
|
||||
if sharedCache != nil {
|
||||
if sharedCache != nil && sharedCache.CacheDir != "" {
|
||||
fsCache, err := openCache()
|
||||
if err == nil {
|
||||
err = fsCache.Trim()
|
||||
|
||||
Vendored
+2
@@ -39,6 +39,8 @@ env GARBLE_TEST_GOVERSION='go1.38.2'
|
||||
env TOOLCHAIN_GOVERSION='go1.38.2'
|
||||
! exec garble build
|
||||
stderr 'Go version "go1\.38\.2" is too new; Go linker patches aren''t available for go1\.27 or later yet'
|
||||
# Ensure we don't create a cache directory in the current dir.
|
||||
! exists build
|
||||
|
||||
# We should accept custom devel strings.
|
||||
env TOOLCHAIN_GOVERSION='go1.26.0-somecustomversion'
|
||||
|
||||
Reference in New Issue
Block a user