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())
|
slog.Info("packages loaded in " + time.Since(start).String())
|
||||||
|
|
||||||
|
// Merge internal and external packages
|
||||||
mergePackages(internalPackages, externalPackages)
|
mergePackages(internalPackages, externalPackages)
|
||||||
|
|
||||||
|
// **Reintroduce combinePackages here**
|
||||||
|
combinePackages(internalPackages)
|
||||||
|
combinePackages(externalPackages)
|
||||||
|
|
||||||
|
// Determine which packages have been updated
|
||||||
updatedPackages := determineUpdatedPackages(internalPackages, externalPackages)
|
updatedPackages := determineUpdatedPackages(internalPackages, externalPackages)
|
||||||
|
|
||||||
|
// Update binary package flags based on updated packages
|
||||||
updateBinaryPackageFlags(updatedPackages)
|
updateBinaryPackageFlags(updatedPackages)
|
||||||
|
|
||||||
currentPackages = updatedPackages
|
updatedPackages.ForEach(func(key string, pkg domain.SourcePackage) bool {
|
||||||
|
currentPackages.Set(key, pkg)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
LastUpdateTime = time.Now()
|
LastUpdateTime = time.Now()
|
||||||
if err := helpers.DBInst.DropPackages(); err != nil {
|
if err := helpers.DBInst.DropPackages(); err != nil {
|
||||||
@ -385,15 +395,6 @@ func chooseVersion(sourceVersion, stanzaVersion string) string {
|
|||||||
return stanzaVersion
|
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 {
|
func nameContains(name string, match []string) bool {
|
||||||
for _, m := range match {
|
for _, m := range match {
|
||||||
if strings.Contains(name, m) {
|
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] {
|
func determineUpdatedPackages(internal, external *haxmap.Map[string, domain.SourcePackage]) *haxmap.Map[string, domain.SourcePackage] {
|
||||||
updated := haxmap.New[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
|
// 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)
|
cmp, err := compareVersions(intPkg.Version, extPkg.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Warn("Version comparison failed", "package", name, "v1", intPkg.Version, "v2", extPkg.Version, "error", err)
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmp < 0 {
|
if cmp < 0 {
|
||||||
// External package has a newer version
|
|
||||||
intPkg.NewVersion = extPkg.Version
|
intPkg.NewVersion = extPkg.Version
|
||||||
intPkg.Status = domain.Stale
|
intPkg.Status = domain.Stale
|
||||||
updated.Set(name, intPkg)
|
updated.Set(name, intPkg)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If the package doesn't exist internally, add it
|
||||||
|
updated.Set(name, extPkg)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
return updated
|
return updated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user