fix: nil pointer exception when (re-)indexing
Alan Pearce alan@alanpearce.eu
Wed, 29 May 2024 16:53:48 +0200
2 files changed, 4 insertions(+), 3 deletions(-)
M internal/fetcher/download.go → internal/fetcher/download.go
@@ -42,6 +42,7 @@ ctx context.Context, sourceMeta *index.SourceMeta, ) (f FetchedFiles, err error) { var fetchURL string + sourceUpdated := sourceMeta.Updated for key, filename := range files { fetchURL, err = url.JoinPath(i.Source.URL, filename) if err != nil { @@ -57,14 +58,14 @@ } i.Logger.Debug("preparing to fetch URL", "url", fetchURL) - body, mtime, err := fetchFileIfNeeded(ctx, sourceMeta.Updated, fetchURL) + body, mtime, err := fetchFileIfNeeded(ctx, sourceUpdated, fetchURL) if err != nil { i.Logger.Warn("failed to fetch file", "url", fetchURL, "error", err) return f, err } // don't bother to issue requests for the later files - if mtime.Before(sourceMeta.Updated) { + if mtime.Before(sourceUpdated) { break } sourceMeta.Updated = mtime
M searchix.go → searchix.go
@@ -64,7 +64,7 @@ replace, "update", update, ) - err = importer.Start(s.cfg, write, replace, nil) + err = importer.Start(s.cfg, write, replace || update, nil) if err != nil { return errors.Wrap(err, "Failed to build index") }