Skip to content

Commit

Permalink
Merge #4250 Exclude DLLs being upgraded to full modules
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 6, 2024
2 parents 49c79d2 + 8c2059e commit 3d17da3
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
- [Multiple] Refactor relationship resolver to capture full resolved tree (#4232 by: HebaruSan)
- [GUI] Fix skipping failed dependency downloads (#4235 by: HebaruSan)
- [Core] Fix reporting of wrong download as failed (#4236 by: HebaruSan)
- [Core] Exclude DLLs being upgraded to full modules (#4250 by: HebaruSan)

### Internal

Expand Down
5 changes: 1 addition & 4 deletions Core/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ Pensez à ajouter un jeton d'authentification pour augmenter la limite avant bri
<data name="KrakenAlreadyRunning" xml:space="preserve">
<value>Fichier verrou avec un ID de processus actif à {0}

Un autre processus CKAN est probablement déjà en train d'accéder à ce dossier de jeu. Si vous êtes sûr que ce fichier verrou est périmé, vous pouvez supprimer ce fichier pour continuer. Mais si ce n'est pas le cas, les deux CKAN risque de rentrer en conflit et corrompre votre registre de mods et votre dossier de jeu.
Un autre processus CKAN est probablement déjà en train d'accéder à ce dossier de jeu. Si vous êtes sûr que ce fichier verrou est périmé, vous pouvez supprimer ce fichier pour continuer. Mais si ce n'est pas le cas, les deux CKAN risque de rentrer en conflit et corrompre votre registre de mods et votre dossier de jeu.

Voulez-vous supprimez ce fichier verrou pour forcer l'accès ?</value>
</data>
Expand Down Expand Up @@ -663,9 +663,6 @@ Libérez de l'espace sur cet appareil ou modifiez vos paramètres pour utiliser
<data name="SanityCheckerUnsatisfiedDependency" xml:space="preserve">
<value>{0} a une dépendance insatisfaite : {1} n'est pas installé</value>
</data>
<data name="SanityCheckerConflictsWith" xml:space="preserve">
<value>{0} est en conflit avec {1}</value>
</data>
<data name="NetModuleCacheMetapackage" xml:space="preserve">
<value>{0} {1} (méta-paquet)</value>
</data>
Expand Down
3 changes: 0 additions & 3 deletions Core/Properties/Resources.it-IT.resx
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,6 @@ Libera spazio su quel dispositivo o modifica le impostazioni per utilizzare un'a
<data name="SanityCheckerUnsatisfiedDependency" xml:space="preserve">
<value>{0} ha una dipendenza non soddisfatta: {1} non è installata</value>
</data>
<data name="SanityCheckerConflictsWith" xml:space="preserve">
<value>{0} conflitti con {1}</value>
</data>
<data name="NetModuleCacheMetapackage" xml:space="preserve">
<value>{0} {1} (metapacchetto)</value>
</data>
Expand Down
3 changes: 0 additions & 3 deletions Core/Properties/Resources.pl-PL.resx
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ Zwolnij miejsce na tym urządzeniu lub zmień ustawienia, aby użyć innej lokal
<data name="SanityCheckerUnsatisfiedDependency" xml:space="preserve">
<value>{0} ma niespełnioną zależność: {1} nie jest zainstalowany</value>
</data>
<data name="SanityCheckerConflictsWith" xml:space="preserve">
<value>{0} koliduje z {1}</value>
</data>
<data name="NetModuleCacheMetapackage" xml:space="preserve">
<value>{0} {1} (metapackage)</value>
</data>
Expand Down
1 change: 0 additions & 1 deletion Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ Free up space on that device or change your settings to use another location.
<data name="RelationshipResolverDependsReason" xml:space="preserve"><value>Dependency of {0}</value></data>
<data name="RelationshipResolverRecommendedReason" xml:space="preserve"><value>Recommended by {0}</value></data>
<data name="SanityCheckerUnsatisfiedDependency" xml:space="preserve"><value>{0} has an unsatisfied dependency: {1} is not installed</value></data>
<data name="SanityCheckerConflictsWith" xml:space="preserve"><value>{0} conflicts with {1}</value></data>
<data name="NetModuleCacheMetapackage" xml:space="preserve"><value>{0} {1} (metapackage)</value></data>
<data name="NetModuleCacheModuleCached" xml:space="preserve"><value>{0} {1} (cached)</value></data>
<data name="NetModuleCacheModuleHostSize" xml:space="preserve"><value>{0} {1} ({2}, {3})</value></data>
Expand Down
1 change: 0 additions & 1 deletion Core/Properties/Resources.ru-RU.resx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ https://github.com/KSP-CKAN/CKAN/wiki/SSL-certificate-errors</value></data>
<data name="RelationshipResolverDependsReason" xml:space="preserve"><value>Для удовлетворения зависимости {0}</value></data>
<data name="RelationshipResolverRecommendedReason" xml:space="preserve"><value>Рекомендуется {0}</value></data>
<data name="SanityCheckerUnsatisfiedDependency" xml:space="preserve"><value>{0} имеет неудовлетворённую зависимость: {1} не установлен</value></data>
<data name="SanityCheckerConflictsWith" xml:space="preserve"><value>{0} конфликтует с {1}</value></data>
<data name="NetModuleCacheMetapackage" xml:space="preserve"><value>{0} {1} (метапакет)</value></data>
<data name="NetModuleCacheModuleCached" xml:space="preserve"><value>{0} {1} (кэшировано)</value></data>
<data name="NetModuleCacheModuleHostSize" xml:space="preserve"><value>{0} {1} ({2}, {3})</value></data>
Expand Down
3 changes: 0 additions & 3 deletions Core/Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,6 @@
<data name="SanityCheckerUnsatisfiedDependency" xml:space="preserve">
<value>{0} 有一个未满足的依赖项: {1} 未安装</value>
</data>
<data name="SanityCheckerConflictsWith" xml:space="preserve">
<value>{0} 与 {1} 冲突</value>
</data>
<data name="NetModuleCacheMetapackage" xml:space="preserve">
<value>{0} {1} (metapackage)</value>
</data>
Expand Down
12 changes: 9 additions & 3 deletions Core/Relationships/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public RelationshipResolver(IEnumerable<CkanModule> modulesToInstall,
}

var toInst = modulesToInstall.ToArray();
resolved = new ResolvedRelationshipsTree(toInst, registry,
// DLLs that we are upgrading to full modules should be excluded
dlls = registry.InstalledDlls
.Except(modulesToInstall.Select(m => m.identifier))
.ToHashSet();
resolved = new ResolvedRelationshipsTree(toInst, registry, dlls,
installed_modules, versionCrit,
options.OptionalHandling());
if (!options.proceed_with_inconsistencies)
Expand Down Expand Up @@ -127,7 +131,7 @@ private void AddModulesToInstall(CkanModule[] modules)
{
// Check that our solution is actually sane
SanityChecker.EnforceConsistency(modlist.Values.Concat(installed_modules),
registry.InstalledDlls,
dlls,
registry.InstalledDlc);
}
catch (BadRelationshipsKraken k) when (options.without_enforce_consistency)
Expand Down Expand Up @@ -276,7 +280,7 @@ private void ResolveStanza(List<RelationshipDescriptor>? stanza,

// If it's already installed, skip.
if (descriptor.MatchesAny(installed_modules,
registry.InstalledDlls,
dlls,
registry.InstalledDlc,
out CkanModule? installedCandidate))
{
Expand Down Expand Up @@ -649,6 +653,8 @@ private void AddReason(CkanModule module, SelectionReason reason)
private readonly Dictionary<CkanModule, List<SelectionReason>> reasons =
new Dictionary<CkanModule, List<SelectionReason>>();

private readonly HashSet<string> dlls;

/// <summary>
/// Depends relationships with suppress_recommendations=true,
/// to be applied to all recommendations and suggestions
Expand Down
3 changes: 2 additions & 1 deletion Core/Relationships/ResolvedRelationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ public ResolvedByNew(CkanModule source,
ICollection<CkanModule> definitelyInstalling,
ICollection<CkanModule> allInstalling,
IRegistryQuerier registry,
ICollection<string> dlls,
ICollection<CkanModule> installed,
GameVersionCriteria crit,
OptionalRelationships optRels,
RelationshipCache relationshipCache)
: this(source, relationship, reason,
providers.ToDictionary(prov => prov,
prov => ResolvedRelationshipsTree.ResolveModule(
prov, definitelyInstalling, allInstalling, registry, installed, crit,
prov, definitelyInstalling, allInstalling, registry, dlls, installed, crit,
relationship.suppress_recommendations
? optRels & ~OptionalRelationships.Recommendations
& ~OptionalRelationships.Suggestions
Expand Down
21 changes: 13 additions & 8 deletions Core/Relationships/ResolvedRelationshipsTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,33 @@ public class ResolvedRelationshipsTree
{
public ResolvedRelationshipsTree(ICollection<CkanModule> modules,
IRegistryQuerier registry,
ICollection<string> dlls,
ICollection<CkanModule> installed,
GameVersionCriteria crit,
OptionalRelationships optRels)
{
resolved = ResolveManyCached(modules, registry, installed, crit, optRels, relationshipCache).ToArray();
resolved = ResolveManyCached(modules, registry, dlls, installed, crit, optRels, relationshipCache).ToArray();
}

public static IEnumerable<ResolvedRelationship> ResolveModule(CkanModule module,
ICollection<CkanModule> definitelyInstalling,
ICollection<CkanModule> allInstalling,
IRegistryQuerier registry,
ICollection<string> dlls,
ICollection<CkanModule> installed,
GameVersionCriteria crit,
OptionalRelationships optRels,
RelationshipCache relationshipCache)
=> ResolveRelationships(module, module.depends, new SelectionReason.Depends(module),
definitelyInstalling, allInstalling, registry, installed, crit, optRels, relationshipCache)
definitelyInstalling, allInstalling, registry, dlls, installed, crit, optRels, relationshipCache)
.Concat((optRels & OptionalRelationships.Recommendations) == 0
? Enumerable.Empty<ResolvedRelationship>()
: ResolveRelationships(module, module.recommends, new SelectionReason.Recommended(module, 0),
definitelyInstalling, allInstalling, registry, installed, crit, optRels, relationshipCache))
definitelyInstalling, allInstalling, registry, dlls, installed, crit, optRels, relationshipCache))
.Concat((optRels & OptionalRelationships.Suggestions) == 0
? Enumerable.Empty<ResolvedRelationship>()
: ResolveRelationships(module, module.suggests, new SelectionReason.Suggested(module),
definitelyInstalling, allInstalling, registry, installed, crit, optRels, relationshipCache));
definitelyInstalling, allInstalling, registry, dlls, installed, crit, optRels, relationshipCache));

public IEnumerable<ResolvedRelationship[]> Unsatisfied()
=> resolved.SelectMany(UnsatisfiedFrom);
Expand Down Expand Up @@ -102,11 +104,12 @@ public override string ToString()

private static IEnumerable<ResolvedRelationship> ResolveManyCached(ICollection<CkanModule> modules,
IRegistryQuerier registry,
ICollection<string> dlls,
ICollection<CkanModule> installed,
GameVersionCriteria crit,
OptionalRelationships optRels,
RelationshipCache relationshipCache)
=> modules.SelectMany(m => ResolveModule(m, modules, modules, registry, installed, crit, optRels,
=> modules.SelectMany(m => ResolveModule(m, modules, modules, registry, dlls, installed, crit, optRels,
relationshipCache));

private static IEnumerable<ResolvedRelationship> ResolveRelationships(CkanModule module,
Expand All @@ -115,12 +118,13 @@ private static IEnumerable<ResolvedRelationship> ResolveRelationships(CkanModule
ICollection<CkanModule> definitelyInstalling,
ICollection<CkanModule> allInstalling,
IRegistryQuerier registry,
ICollection<string> dlls,
ICollection<CkanModule> installed,
GameVersionCriteria crit,
OptionalRelationships optRels,
RelationshipCache relationshipCache)
=> relationships?.Select(dep => Resolve(module, dep, reason,
definitelyInstalling, allInstalling, registry, installed,
definitelyInstalling, allInstalling, registry, dlls, installed,
crit, optRels, relationshipCache))
?? Enumerable.Empty<ResolvedRelationship>();

Expand All @@ -130,14 +134,15 @@ private static ResolvedRelationship Resolve(CkanModule source,
ICollection<CkanModule> definitelyInstalling,
ICollection<CkanModule> allInstalling,
IRegistryQuerier registry,
ICollection<string> dlls,
ICollection<CkanModule> installed,
GameVersionCriteria crit,
OptionalRelationships optRels,
RelationshipCache relationshipCache)
=> relationshipCache.TryGetValue(relationship,
out ResolvedRelationship? cachedRel)
? cachedRel.WithSource(source, reason)
: relationship.MatchesAny(installed, registry.InstalledDlls, registry.InstalledDlc,
: relationship.MatchesAny(installed, dlls, registry.InstalledDlc,
out CkanModule? installedMatch)
? relationshipCache.GetOrAdd(
relationship,
Expand All @@ -156,7 +161,7 @@ private static ResolvedRelationship Resolve(CkanModule source,
installed, definitelyInstalling),
definitelyInstalling,
allInstalling.Append(source).ToArray(),
registry, installed, crit, optRels,
registry, dlls, installed, crit, optRels,
relationshipCache));

private readonly ResolvedRelationship[] resolved;
Expand Down
8 changes: 8 additions & 0 deletions Netkan/Extensions/JObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ public static void SafeMerge(this JObject jobject, string propertyName, JToken?
}
}

public static void SafeMerge(this JObject jobject, JObject other)
{
foreach (var property in other.Properties())
{
jobject.SafeAdd(property.Name, property.Value);
}
}

public static JToken? ToJValueOrJArray<T>(this IEnumerable<T?> source) where T: notnull
{
var items = source.OfType<T>()
Expand Down
Loading

0 comments on commit 3d17da3

Please sign in to comment.