Improve optional dependency detection during package installation

This commit is contained in:
2026-06-21 09:47:28 +03:00
parent a496777b9e
commit e6456105e1
+26 -2
View File
@@ -449,7 +449,7 @@ func (operation *BPMOperation) GetOptionalDependencies() (optionalDepends map[st
optionalDepends = make(map[string][]string) optionalDepends = make(map[string][]string)
// Find all optional dependencies // Find all optional dependencies
for _, value := range slices.Clone(operation.Actions) { for _, value := range operation.Actions {
var pkgInfo *PackageInfo var pkgInfo *PackageInfo
if value.GetActionType() == "install" { if value.GetActionType() == "install" {
action := value.(*InstallPackageAction) action := value.(*InstallPackageAction)
@@ -467,7 +467,31 @@ func (operation *BPMOperation) GetOptionalDependencies() (optionalDepends map[st
dependName, _, _ := SplitPkgNameAndVersion(dependSplit[0]) dependName, _, _ := SplitPkgNameAndVersion(dependSplit[0])
// Skip if dependency is already installed // Skip if dependency is already installed
if IsPackageInstalled(dependName, operation.RootDir) { if IsPackageInstalled(dependName, operation.RootDir) || len(GetVirtualPackageInfo(dependName, operation.RootDir)) > 0 {
continue
}
// Skip if dependency is going to be installed
if slices.IndexFunc(operation.Actions, func(action OperationAction) bool {
var pkgInfo *PackageInfo
if action.GetActionType() == "install" {
action := action.(*InstallPackageAction)
pkgInfo = action.BpmPackage.PkgInfo
} else if action.GetActionType() == "fetch" {
action := action.(*FetchPackageAction)
pkgInfo = action.DatabaseEntry.Info
} else {
return false
}
if pkgInfo.Name == dependName {
return true
} else if slices.Contains(pkgInfo.Provides, dependName) {
return true
}
return false
}) != -1 {
continue continue
} }