From 994d2d2aba1e983bbedd0de070abef5f25150379 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 10 Jan 2023 22:29:38 +0100 Subject: [PATCH] Fix version compare failing when old version is not present Signed-off-by: Knut Ahlers --- internal/version/constraint.go | 5 +++++ scheduler.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/version/constraint.go b/internal/version/constraint.go index 87496cf..f10e04c 100644 --- a/internal/version/constraint.go +++ b/internal/version/constraint.go @@ -26,6 +26,11 @@ const ( ) func (c Constraint) ShouldApply(oldVersion, newVersion string) (bool, error) { + if oldVersion == "" && newVersion != "" { + // The old version does not exist, the new one does, update it! + return true, nil + } + comp := c.getComparer() if comp == nil { return false, errors.New("invalid version type specified") diff --git a/scheduler.go b/scheduler.go index a100bd7..1a601fd 100644 --- a/scheduler.go +++ b/scheduler.go @@ -79,7 +79,7 @@ func checkForUpdates(ce *database.CatalogEntry) error { cm.Error = err.Error() case compareErr != nil: - logger.WithError(err).Error("Version compare caused error, error is stored in entry") + logger.WithError(compareErr).Error("Version compare caused error, error is stored in entry") cm.Error = compareErr.Error() case cm.CurrentVersion != ver && !shouldUpdate: