Skip to content

Commit

Permalink
Merge #2259 Resolve provides for install-from-ckan-file
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Jan 26, 2018
2 parents 989b998 + 923c8e9 commit 3cb2027
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.

- [Multiple] Save timestamped .ckan files after we save the registry (#2239 by: HebaruSan; reviewed: politas)
- [GUI] Add status and progress bar at the bottom of the window (#2245 by: HebaruSan; reviewed: Olympic1)
- [GUI] Add import downloads menu item to GUI (#2246 by: HebaruSan; reviewed: politas)

### Bugfixes

Expand All @@ -16,6 +17,8 @@ All notable changes to this project will be documented in this file.
- [GUI] Allow uninstallation of mods while Incompatible filter is selected (#2242 by: HebaruSan; reviewed: politas)
- [Core] Validate downloaded files against metadata before adding to cache (#2243 by: HebaruSan; reviewed: politas)
- [Core] Fix missing filename in install -c log message (No PR, by: HebaruSan)
- [GUI] Leave out children already shown in ancestor node (#2258 by: HebaruSan; reviewed: politas)
- [GUI] Resolve provides for install-from-ckan-file (#2259 by: HebaruSan; reviewed: politas)

## v1.24.0-PRE1 (McCandless)

Expand Down
61 changes: 45 additions & 16 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ private void pluginsToolStripMenuItem_Click(object sender, EventArgs e)
Enabled = true;
}

private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
private async void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog open_file_dialog = new OpenFileDialog { Filter = Resources.CKANFileFilter };

Expand Down Expand Up @@ -939,26 +939,55 @@ private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
// Sneakily add our version in...
registry_manager.registry.AddAvailable(module);

var changeset = new List<ModChange>
{
new ModChange(
new GUIMod(module, registry_manager.registry, CurrentInstance.VersionCriteria()),
GUIModChangeType.Install, null)
};

menuStrip1.Enabled = false;

RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts();
install_ops.with_recommends = false;

installWorker.RunWorkerAsync(
new KeyValuePair<List<ModChange>, RelationshipResolverOptions>(
changeset, install_ops));

changeSet = null;

UpdateChangesDialog(null, installWorker);
ShowWaitDialog();
try
{
// Resolve the provides relationships in the dependencies
List<ModChange> fullChangeSet = new List<ModChange>(
await mainModList.ComputeChangeSetFromModList(
registry_manager.registry,
new HashSet<ModChange>()
{
new ModChange(
new GUIMod(
module,
registry_manager.registry,
CurrentInstance.VersionCriteria()
),
GUIModChangeType.Install,
null
)
},
ModuleInstaller.GetInstance(CurrentInstance, GUI.user),
CurrentInstance.VersionCriteria()
)
);
if (fullChangeSet != null && fullChangeSet.Count > 0)
{
installWorker.RunWorkerAsync(
new KeyValuePair<List<ModChange>, RelationshipResolverOptions>(
fullChangeSet,
install_ops
)
);
UpdateChangesDialog(null, installWorker);
ShowWaitDialog();
}
}
catch
{
// If we failed, do the clean-up normally done by PostInstallMods.
HideWaitDialog(false);
menuStrip1.Enabled = true;
}
finally
{
changeSet = null;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ public async Task<IEnumerable<ModChange>> ComputeChangeSetFromModList(
var installed_modules =
registry.InstalledModules.Select(imod => imod.Module).ToDictionary(mod => mod.identifier, mod => mod);

bool handled_all_to_many_provides = false;
while (!handled_all_to_many_provides)
bool handled_all_too_many_provides = false;
while (!handled_all_too_many_provides)
{
//Can't await in catch clause - doesn't seem to work in mono. Hence this flag
TooManyModsProvideKraken kraken;
try
{
new RelationshipResolver(modules_to_install.ToList(), options, registry, version);
handled_all_to_many_provides = true;
handled_all_too_many_provides = true;
continue;
}
catch (TooManyModsProvideKraken k)
Expand Down

0 comments on commit 3cb2027

Please sign in to comment.