]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.15] cmd/go/internal/modfetch: detect and recover from missing...
authorJay Conrod <jayconrod@google.com>
Wed, 3 Mar 2021 21:30:22 +0000 (16:30 -0500)
committerAlexander Rakoczy <alex@golang.org>
Thu, 25 Mar 2021 18:28:32 +0000 (18:28 +0000)
commit7038a380bcd0183842471c1984da491e044d3d34
tree78b7e7335ad29bf3d706a8d324c8ac78371463fd
parentdcffdac515a1d409bcb61783d57ddb137b4741b9
[release-branch.go1.15] cmd/go/internal/modfetch: detect and recover from missing ziphash file

Previously, if an extracted module directory existed in the module
cache, but the corresponding ziphash file did not, if the sum was
missing from go.sum, we would not verify the sum. This caused 'go get'
not to write missing sums. 'go build' in readonly mode (now the
default) checks for missing sums and doesn't attempt to fetch modules
that can't be verified against go.sum.

With this change, when requesting the module directory with
modfetch.DownloadDir, if the ziphash file is missing, the go command
will re-hash the zip without downloading or re-extracting it again.

Note that the go command creates the ziphash file before the module
directory, but another program could remove it separately, and it
might not be present after a crash.

Fixes #44872

Change-Id: I64551e048a3ba17d069de1ec123d5b8b2757543c
Reviewed-on: https://go-review.googlesource.com/c/go/+/298352
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 302a400316319501748c0f034464fa70e7815272)
Reviewed-on: https://go-review.googlesource.com/c/go/+/299830
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/modfetch/fetch.go
src/cmd/go/testdata/script/mod_get_missing_ziphash.txt [new file with mode: 0644]
src/cmd/go/testdata/script/mod_verify.txt