Commit f938b9b3 authored by Heschi Kreinick's avatar Heschi Kreinick

cmd/go: fix typo in sumdb cache path

Put the sumdb cache in the usual pkg/mod/cache/download dir, rather
than the new pkg/mod/download/cache dir which I presume was a typo.

Change-Id: Id162f24db30f509353178ca0c8cc7a4dabc927e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/183318
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent 9acd2d60
...@@ -232,10 +232,10 @@ func (*dbClient) WriteConfig(file string, old, new []byte) error { ...@@ -232,10 +232,10 @@ func (*dbClient) WriteConfig(file string, old, new []byte) error {
} }
// ReadCache reads cached lookups or tiles from // ReadCache reads cached lookups or tiles from
// GOPATH/pkg/mod/download/cache/sumdb, // GOPATH/pkg/mod/cache/download/sumdb,
// which will be deleted by "go clean -modcache". // which will be deleted by "go clean -modcache".
func (*dbClient) ReadCache(file string) ([]byte, error) { func (*dbClient) ReadCache(file string) ([]byte, error) {
targ := filepath.Join(PkgMod, "download/cache/sumdb", file) targ := filepath.Join(PkgMod, "cache/download/sumdb", file)
data, err := lockedfile.Read(targ) data, err := lockedfile.Read(targ)
// lockedfile.Write does not atomically create the file with contents. // lockedfile.Write does not atomically create the file with contents.
// There is a moment between file creation and locking the file for writing, // There is a moment between file creation and locking the file for writing,
...@@ -249,7 +249,7 @@ func (*dbClient) ReadCache(file string) ([]byte, error) { ...@@ -249,7 +249,7 @@ func (*dbClient) ReadCache(file string) ([]byte, error) {
// WriteCache updates cached lookups or tiles. // WriteCache updates cached lookups or tiles.
func (*dbClient) WriteCache(file string, data []byte) { func (*dbClient) WriteCache(file string, data []byte) {
targ := filepath.Join(PkgMod, "download/cache/sumdb", file) targ := filepath.Join(PkgMod, "cache/download/sumdb", file)
os.MkdirAll(filepath.Dir(targ), 0777) os.MkdirAll(filepath.Dir(targ), 0777)
lockedfile.Write(targ, bytes.NewReader(data), 0666) lockedfile.Write(targ, bytes.NewReader(data), 0666)
} }
......
...@@ -28,7 +28,7 @@ cp go.mod.orig go.mod ...@@ -28,7 +28,7 @@ cp go.mod.orig go.mod
rm go.sum rm go.sum
env GOPROXY=off env GOPROXY=off
go get -d rsc.io/quote@v1.5.2 # using cache go get -d rsc.io/quote@v1.5.2 # using cache
rm $GOPATH/pkg/mod/download/cache/sumdb/localhost.localdev/sumdb/lookup/rsc.io/quote@v1.5.2 rm $GOPATH/pkg/mod/cache/download/sumdb/localhost.localdev/sumdb/lookup/rsc.io/quote@v1.5.2
go get -d rsc.io/quote@v1.5.2 # using go.sum go get -d rsc.io/quote@v1.5.2 # using go.sum
# fetch fails once we lose access to both cache and go.sum # fetch fails once we lose access to both cache and go.sum
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
env GO111MODULE=on env GO111MODULE=on
env GOSUMDB= env GOSUMDB=
env GOPATH=$WORK/gopath1
# With a file-based proxy with an empty checksum directory, # With a file-based proxy with an empty checksum directory,
# downloading a new module should fail, even if a subsequent # downloading a new module should fail, even if a subsequent
...@@ -18,11 +19,20 @@ stderr '^verifying golang.org/x/text.*: Not Found' ...@@ -18,11 +19,20 @@ stderr '^verifying golang.org/x/text.*: Not Found'
[!windows] env GOPROXY=file://$WORK/emptyproxy,https://proxy.golang.org [!windows] env GOPROXY=file://$WORK/emptyproxy,https://proxy.golang.org
go get -d golang.org/x/text@v0.3.2 go get -d golang.org/x/text@v0.3.2
# After a successful sumdb lookup, the lookup can be repeated
# using the download cache as a proxy.
cp supported $GOPATH/pkg/mod/cache/download/sumdb/sum.golang.org/supported
[windows] env GOPROXY=file:///$WORK/gopath1/pkg/mod/cache/download,file:///$WORK/sumproxy
[!windows] env GOPROXY=file://$WORK/gopath1/pkg/mod/cache/download,file://$WORK/sumproxy
env GOPATH=$WORK/gopath2
rm go.sum
go get -d -x -v golang.org/x/text@v0.3.2
# Once the checksum is present in the go.sum file, # Once the checksum is present in the go.sum file,
# an empty file-based sumdb can be used in conjunction with # an empty file-based sumdb can be used in conjunction with
# a fallback module mirror. # a fallback module mirror.
grep golang.org/x/text go.sum grep golang.org/x/text go.sum
go clean -modcache env GOPATH=$WORK/gopath3
[windows] env GOPROXY=file:///$WORK/sumproxy [windows] env GOPROXY=file:///$WORK/sumproxy
[!windows] env GOPROXY=file://$WORK/sumproxy [!windows] env GOPROXY=file://$WORK/sumproxy
! go get -d golang.org/x/text@v0.3.2 ! go get -d golang.org/x/text@v0.3.2
...@@ -30,6 +40,8 @@ go clean -modcache ...@@ -30,6 +40,8 @@ go clean -modcache
[!windows] env GOPROXY=file://$WORK/sumproxy,https://proxy.golang.org [!windows] env GOPROXY=file://$WORK/sumproxy,https://proxy.golang.org
go get -d golang.org/x/text@v0.3.2 go get -d golang.org/x/text@v0.3.2
-- supported --
-- go.mod -- -- go.mod --
module example.com module example.com
go 1.13 go 1.13
......
...@@ -6,14 +6,14 @@ env GOPROXY GONOPROXY GOSUMDB GONOSUMDB ...@@ -6,14 +6,14 @@ env GOPROXY GONOPROXY GOSUMDB GONOSUMDB
# basic fetch (through proxy) works # basic fetch (through proxy) works
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get -d rsc.io/fortune@v1.0.0 # note: must use test proxy, does not exist in real world go get -d rsc.io/fortune@v1.0.0 # note: must use test proxy, does not exist in real world
rm $GOPATH/pkg/mod/download/cache/sumdb # rm sumdb cache but NOT package download cache rm $GOPATH/pkg/mod/cache/download/sumdb # rm sumdb cache but NOT package download cache
rm go.sum rm go.sum
# can fetch by explicit URL # can fetch by explicit URL
cp go.mod.orig go.mod cp go.mod.orig go.mod
env GOSUMDB=$sumdb' '$proxy/sumdb-direct env GOSUMDB=$sumdb' '$proxy/sumdb-direct
go get -d rsc.io/fortune@v1.0.0 go get -d rsc.io/fortune@v1.0.0
rm $GOPATH/pkg/mod/download/cache/sumdb rm $GOPATH/pkg/mod/cache/download/sumdb
rm go.sum rm go.sum
# direct access fails (because localhost.localdev does not exist) # direct access fails (because localhost.localdev does not exist)
...@@ -25,7 +25,7 @@ env GOSUMDB=$sumdb ...@@ -25,7 +25,7 @@ env GOSUMDB=$sumdb
env GOPROXY=direct env GOPROXY=direct
! go get -d rsc.io/fortune@v1.0.0 ! go get -d rsc.io/fortune@v1.0.0
stderr 'verifying.*localhost.localdev' stderr 'verifying.*localhost.localdev'
rm $GOPATH/pkg/mod/download/cache/sumdb rm $GOPATH/pkg/mod/cache/download/sumdb
rm go.sum rm go.sum
# proxy 404 falls back to direct access (which fails) # proxy 404 falls back to direct access (which fails)
...@@ -34,7 +34,7 @@ env GOSUMDB=$sumdb ...@@ -34,7 +34,7 @@ env GOSUMDB=$sumdb
env GOPROXY=$proxy/sumdb-404 env GOPROXY=$proxy/sumdb-404
! go get -d rsc.io/fortune@v1.0.0 ! go get -d rsc.io/fortune@v1.0.0
stderr 'verifying.*localhost.localdev' stderr 'verifying.*localhost.localdev'
rm $GOPATH/pkg/mod/download/cache/sumdb rm $GOPATH/pkg/mod/cache/download/sumdb
rm go.sum rm go.sum
# proxy non-200/404/410 stops direct access # proxy non-200/404/410 stops direct access
...@@ -43,7 +43,7 @@ env GOSUMDB=$sumdb ...@@ -43,7 +43,7 @@ env GOSUMDB=$sumdb
env GOPROXY=$proxy/sumdb-503 env GOPROXY=$proxy/sumdb-503
! go get -d rsc.io/fortune@v1.0.0 ! go get -d rsc.io/fortune@v1.0.0
stderr '503 Service Unavailable' stderr '503 Service Unavailable'
rm $GOPATH/pkg/mod/download/cache/sumdb rm $GOPATH/pkg/mod/cache/download/sumdb
rm go.sum rm go.sum
-- go.mod.orig -- -- go.mod.orig --
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment