Skip to content

Commit

Permalink
internal/worker: move raw-latest computation to FetchAndUpdateState
Browse files Browse the repository at this point in the history
To make sure it happens in our integration test.

For golang/go#44437

Change-Id: I0e921b067f6798d108880eae152edc5264168e74
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296814
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
  • Loading branch information
jba committed Feb 26, 2021
1 parent db6feab commit 4ae3818
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 8 additions & 0 deletions internal/worker/fetch.go
Expand Up @@ -67,6 +67,14 @@ func (f *Fetcher) FetchAndUpdateState(ctx context.Context, modulePath, requested
trace.StringAttribute("version", requestedVersion))
defer span.End()

// Whenever we fetch a module, make sure its raw latest information is up to
// date in the DB.
if err := f.fetchAndUpdateRawLatest(ctx, modulePath); err != nil {
// Do not fail the fetch just because we couldn't update the raw latest info.
log.Errorf(ctx, "updating raw latest: %v", err)
derrors.Report(err)
}

ft := f.fetchAndInsertModule(ctx, modulePath, requestedVersion)
span.AddAttributes(trace.Int64Attribute("numPackages", int64(len(ft.PackageVersionStates))))

Expand Down
8 changes: 0 additions & 8 deletions internal/worker/server.go
Expand Up @@ -305,14 +305,6 @@ func (s *Server) doFetch(w http.ResponseWriter, r *http.Request) (string, int) {
if r.FormValue(queue.DisableProxyFetchParam) == queue.DisableProxyFetchValue {
f.ProxyClient = f.ProxyClient.WithFetchDisabled()
}
// Whenever we fetch a module, make sure its raw latest information is up to
// date in the DB.
if err := f.fetchAndUpdateRawLatest(ctx, modulePath); err != nil {
// Do not fail the fetch just because we couldn't update the raw latest info.
log.Errorf(ctx, "updating raw latest: %v", err)
derrors.Report(err)
}

code, resolvedVersion, err := f.FetchAndUpdateState(ctx, modulePath, requestedVersion, s.cfg.AppVersionLabel())
if code == http.StatusInternalServerError {
s.reportError(ctx, err, w, r)
Expand Down

0 comments on commit 4ae3818

Please sign in to comment.