diff options
author | Alan Pearce | 2024-05-29 16:53:48 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-29 16:53:48 +0200 |
commit | 2c4a19ad6cb71065d31304370708c859b4f68f6d (patch) | |
tree | bf9a5561066fd62198c7efcd2c15bf69e14ce2f7 /internal/fetcher | |
parent | 10774c3b734d4b32f34a943e8a71a27b357b2ac5 (diff) | |
download | searchix-2c4a19ad6cb71065d31304370708c859b4f68f6d.tar.lz searchix-2c4a19ad6cb71065d31304370708c859b4f68f6d.tar.zst searchix-2c4a19ad6cb71065d31304370708c859b4f68f6d.zip |
fix: nil pointer exception when (re-)indexing
Diffstat (limited to 'internal/fetcher')
-rw-r--r-- | internal/fetcher/download.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/fetcher/download.go b/internal/fetcher/download.go index 59ef8d1..7de6f26 100644 --- a/internal/fetcher/download.go +++ b/internal/fetcher/download.go @@ -42,6 +42,7 @@ func (i *DownloadFetcher) FetchIfNeeded( 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 @@ func (i *DownloadFetcher) FetchIfNeeded( 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 |