]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.16] 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:35 +0000 (18:28 +0000)
commit33fb47921f65d941b232da2ab542191c9978b4dc
tree09ceea7ac85175a7b9edb95ef4a84e4f70c81a6e
parent902d16e97bffe3faf49f48e67c43f7a0827f862c
[release-branch.go1.16] 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 #44812

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/+/298851
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