diff --git a/internal/worker/fetch.go b/internal/worker/fetch.go index 4b97088e9..938d61080 100644 --- a/internal/worker/fetch.go +++ b/internal/worker/fetch.go @@ -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)))) diff --git a/internal/worker/server.go b/internal/worker/server.go index 193da9d73..6b21248f1 100644 --- a/internal/worker/server.go +++ b/internal/worker/server.go @@ -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)