Fix issue with package parsing
This commit is contained in:
parent
480fb614f4
commit
392777475a
@ -58,13 +58,23 @@ func ProcessPackages() error {
|
||||
}
|
||||
slog.Info("packages loaded in " + time.Since(start).String())
|
||||
|
||||
// Merge internal and external packages
|
||||
mergePackages(internalPackages, externalPackages)
|
||||
|
||||
// **Reintroduce combinePackages here**
|
||||
combinePackages(internalPackages)
|
||||
combinePackages(externalPackages)
|
||||
|
||||
// Determine which packages have been updated
|
||||
updatedPackages := determineUpdatedPackages(internalPackages, externalPackages)
|
||||
|
||||
// Update binary package flags based on updated packages
|
||||
updateBinaryPackageFlags(updatedPackages)
|
||||
|
||||
currentPackages = updatedPackages
|
||||
updatedPackages.ForEach(func(key string, pkg domain.SourcePackage) bool {
|
||||
currentPackages.Set(key, pkg)
|
||||
return true
|
||||
})
|
||||
|
||||
LastUpdateTime = time.Now()
|
||||
if err := helpers.DBInst.DropPackages(); err != nil {
|
||||
@ -385,15 +395,6 @@ func chooseVersion(sourceVersion, stanzaVersion string) string {
|
||||
return stanzaVersion
|
||||
}
|
||||
|
||||
func shouldUpdatePackage(packages *haxmap.Map[string, domain.PackageInfo], name string, ver version.Version) bool {
|
||||
existingPkg, exists := packages.Get(name)
|
||||
if !exists {
|
||||
return true
|
||||
}
|
||||
existingVer, _ := version.Parse(existingPkg.Version)
|
||||
return version.Compare(ver, existingVer) >= 0
|
||||
}
|
||||
|
||||
func nameContains(name string, match []string) bool {
|
||||
for _, m := range match {
|
||||
if strings.Contains(name, m) {
|
||||
@ -482,31 +483,27 @@ func mergePackages(internal, external *haxmap.Map[string, domain.SourcePackage])
|
||||
|
||||
func determineUpdatedPackages(internal, external *haxmap.Map[string, domain.SourcePackage]) *haxmap.Map[string, domain.SourcePackage] {
|
||||
updated := haxmap.New[string, domain.SourcePackage]()
|
||||
internal.ForEach(func(name string, intPkg domain.SourcePackage) bool {
|
||||
extPkg, exists := external.Get(name)
|
||||
if !exists {
|
||||
// Package does not exist externally; consider it as potentially updated
|
||||
updated.Set(name, intPkg)
|
||||
return true
|
||||
}
|
||||
|
||||
// Compare internal package version with external package version
|
||||
cmp, err := compareVersions(intPkg.Version, extPkg.Version)
|
||||
if err != nil {
|
||||
slog.Warn("Version comparison failed", "package", name, "v1", intPkg.Version, "v2", extPkg.Version, "error", err)
|
||||
// Depending on requirements, decide whether to skip or consider as updated
|
||||
return true
|
||||
// Now, update the packages that have newer versions
|
||||
external.ForEach(func(name string, extPkg domain.SourcePackage) bool {
|
||||
if intPkg, exists := internal.Get(name); exists {
|
||||
cmp, err := compareVersions(intPkg.Version, extPkg.Version)
|
||||
if err != nil {
|
||||
slog.Warn("Version comparison failed", "package", name, "v1", intPkg.Version, "v2", extPkg.Version, "error", err)
|
||||
return true
|
||||
}
|
||||
if cmp < 0 {
|
||||
intPkg.NewVersion = extPkg.Version
|
||||
intPkg.Status = domain.Stale
|
||||
updated.Set(name, intPkg)
|
||||
}
|
||||
} else {
|
||||
// If the package doesn't exist internally, add it
|
||||
updated.Set(name, extPkg)
|
||||
}
|
||||
|
||||
if cmp < 0 {
|
||||
// External package has a newer version
|
||||
intPkg.NewVersion = extPkg.Version
|
||||
intPkg.Status = domain.Stale
|
||||
updated.Set(name, intPkg)
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
return updated
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user