aboutsummaryrefslogtreecommitdiff
path: root/internal/fetchdatasource/fetchdatasource.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-08-25 09:53:35 -0400
committerJonathan Amsterdam <jba@google.com>2021-08-26 13:55:00 +0000
commitac26f27d709d79ebdecdd54b17fb285579d96377 (patch)
treee7c575ee4ac2e2e5bcd69446c85930df9fde66f9 /internal/fetchdatasource/fetchdatasource.go
parentefd7b89bea98a056cf6ef213a6c0f0305fe5924a (diff)
downloadgo-x-pkgsite-ac26f27d709d79ebdecdd54b17fb285579d96377.tar.xz
internal/fetchdatasource: ignore latest-version errors
A FetchDataSource may be configured with a proxy for latest-version information while still being used for local modules. So ignore latest-version errors. For golang/go#47780 Change-Id: I30448e133faec80002194df59e6f2db449f80625 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/345249 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/fetchdatasource/fetchdatasource.go')
-rw-r--r--internal/fetchdatasource/fetchdatasource.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/fetchdatasource/fetchdatasource.go b/internal/fetchdatasource/fetchdatasource.go
index 896899d5..69f803eb 100644
--- a/internal/fetchdatasource/fetchdatasource.go
+++ b/internal/fetchdatasource/fetchdatasource.go
@@ -103,16 +103,15 @@ func (ds *FetchDataSource) getModule(ctx context.Context, modulePath, version st
m, err := ds.fetch(ctx, modulePath, version)
if m != nil && ds.opts.ProxyClientForLatest != nil {
// Use the go.mod file at the raw latest version to fill in deprecation
- // and retraction information.
- lmv, err2 := fetch.LatestModuleVersions(ctx, modulePath, ds.opts.ProxyClientForLatest, nil)
- if err2 != nil {
- err = err2
- } else {
+ // and retraction information. Ignore any problems getting the
+ // information, because we may be trying to do this for a local module
+ // that the proxy doesn't know about.
+ if lmv, err := fetch.LatestModuleVersions(ctx, modulePath, ds.opts.ProxyClientForLatest, nil); err == nil {
lmv.PopulateModuleInfo(&m.ModuleInfo)
}
}
- // Don't cache cancellations.
+ // Cache both successes and failures, but not cancellations.
if !errors.Is(err, context.Canceled) {
ds.cachePut(modulePath, version, m, err)
}