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