1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:14:40 -07:00

go/packages/packagestest: make temp directory writeable

In module mode, the temp dir will contain a mod cache, which needs to be
made writeable before it can be deleted.

Change-Id: Ia979a8b06d1b4db47d25ffdfdf925ba8a0ac67de
Reviewed-on: https://go-review.googlesource.com/c/156078
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Heschi Kreinick 2019-01-02 14:39:27 -05:00
parent 9ea1c200b2
commit 498d954934

View File

@ -277,6 +277,16 @@ func (e *Exported) Cleanup() {
log.Printf("Skipping cleanup of temp dir: %s", e.temp) log.Printf("Skipping cleanup of temp dir: %s", e.temp)
return return
} }
// Make everything read-write so that the Module exporter's module cache can be deleted.
filepath.Walk(e.temp, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if info.IsDir() {
os.Chmod(path, 0777)
}
return nil
})
os.RemoveAll(e.temp) // ignore errors os.RemoveAll(e.temp) // ignore errors
e.temp = "" e.temp = ""
} }