diff --git a/buildqueue/worker.go b/buildqueue/worker.go index cfec8b8..192d96d 100644 --- a/buildqueue/worker.go +++ b/buildqueue/worker.go @@ -12,6 +12,7 @@ import ( "time" "golang.org/x/net/html" + "pault.ag/go/debian/version" ) func StartPackageQueueWorker(ctx context.Context) { @@ -34,22 +35,34 @@ func StartPackageQueueWorker(ctx context.Context) { if v.Status == domain.Current { return true } - version := v.NewVersion - if version == "" { - version = v.Version + vs := v.NewVersion + if vs == "" { + vs = v.Version } - if v.Status == domain.Missing { + if v.LastBuildStatus == domain.Error { + if v.BuildAttempts > 0 { + buildAttempt = v.BuildAttempts + } + } + if v.Status == domain.Missing || v.Status == domain.Stale { needsBuild = true - buildVersion = version - buildAttempt = v.BuildAttempts - return false } - if v.Status == domain.Stale { - needsBuild = true - buildVersion = version - buildAttempt = v.BuildAttempts - return false + if buildVersion == "" { + buildVersion = vs + } else { + ver, err := version.Parse(buildVersion) + if err != nil { + return true + } + vsVer, err := version.Parse(vs) + if err != nil { + return true + } + if version.Compare(ver, vsVer) < 0 { + buildVersion = vs + } } + return true }) if needsBuild {