[updates] fix: Initial update failed due to the published date of the actual index being in the past

This commit is contained in:
Alexandr Stelnykovych 2025-03-26 18:03:29 +02:00
parent 776b4860ef
commit 149e1609bb

View file

@ -205,9 +205,16 @@ func New(instance instance, name string, cfg Config) (*Updater, error) {
Name: configure.DefaultBinaryIndexName,
Version: info.VersionNumber(),
})
if err == nil && index.init(currentPlatform) == nil {
module.index = index
return module, nil
if err == nil {
// As the index is generated from the current directory,
// we must set the published date to a fixed point in the past.
// New indexes will only be considered if their published date is later than the current one.
index.Published = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
if index.init(currentPlatform) == nil {
module.index = index
return module, nil
}
}
// Fall back to empty index.