Skip to content

Commit

Permalink
Don't prompt user to choose conflicting modules
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Aug 10, 2021
1 parent 241741f commit 5b0af47
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Core/Registry/AvailableModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ private static bool DependsAndConflictsOK(CkanModule module, IEnumerable<CkanMod
}
}
}
var othersMinusSelf = others.Where(m => m.identifier != module.identifier).Memoize();
if (module.conflicts != null)
{
// Skip self-conflicts (but catch other modules providing self)
var othersMinusSelf = others.Where(m => m.identifier != module.identifier).Memoize();
foreach (RelationshipDescriptor rel in module.conflicts)
{
// If any of the conflicts are present, fail
Expand All @@ -144,6 +144,21 @@ private static bool DependsAndConflictsOK(CkanModule module, IEnumerable<CkanMod
}
}
}
// Check reverse conflicts so user isn't prompted to choose modules that will error out immediately
var selfArray = new CkanModule[] { module };
foreach (CkanModule other in othersMinusSelf)
{
if (other.conflicts != null)
{
foreach (RelationshipDescriptor rel in other.conflicts)
{
if (rel.MatchesAny(selfArray, null, null))
{
return false;
}
}
}
}
return true;
}

Expand Down

0 comments on commit 5b0af47

Please sign in to comment.