Fix daily download logic to fetch previous days update, rather than todays which is not the correct file.
All checks were successful
Go Test / test (push) Successful in 33s

This commit is contained in:
Fred Boniface 2024-04-20 08:50:08 +01:00
parent db3d6030d5
commit 74e9b1b344

View File

@ -122,16 +122,21 @@ func runCifUpdateDownload(cfg *helpers.Configuration, metadata *dbAccess.CifMeta
return nil 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) { func fetchUpdate(t time.Time, cfg *helpers.Configuration) (io.ReadCloser, error) {
url, err := getUpdateUrl("daily") url, err := getUpdateUrl("daily")
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Append day string to URL // Calcuates the day yesterday which is the file that needs downloading
url = url + getDayString(t) 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) dataStream, err := nrod.NrodStream(url, cfg)
if err != nil { if err != nil {
return nil, err return nil, err