From 74e9b1b344059c3214b83a45861dde61236099f3 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 20 Apr 2024 08:50:08 +0100 Subject: [PATCH] Fix daily download logic to fetch previous days update, rather than todays which is not the correct file. --- cif/update.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cif/update.go b/cif/update.go index 8600c2f..cc5e560 100644 --- a/cif/update.go +++ b/cif/update.go @@ -122,16 +122,21 @@ func runCifUpdateDownload(cfg *helpers.Configuration, metadata *dbAccess.CifMeta return nil } -// Wraps nrod.NrodDownload() into a function which can handle downloading data for a given day +// Wraps nrod.NrodDownload() into a function which can handle downloading data for a given day. +// Note that the previous days update is the latest and is downloaded. func fetchUpdate(t time.Time, cfg *helpers.Configuration) (io.ReadCloser, error) { url, err := getUpdateUrl("daily") if err != nil { return nil, err } - // Append day string to URL - url = url + getDayString(t) + // Calcuates the day yesterday which is the file that needs downloading + updateDay := t.Add(-24 * time.Hour) + // Append day string to URL + url = url + getDayString(updateDay) + + log.Debug("Fetching CIF Data", zap.Time("Update_File_Produced", updateDay)) dataStream, err := nrod.NrodStream(url, cfg) if err != nil { return nil, err