Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: KSP-CKAN/CKAN
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a7ebcfd45cca
Choose a base ref
...
head repository: KSP-CKAN/CKAN
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c536f131378a
Choose a head ref
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Dec 19, 2018

  1. Copy the full SHA
    cea8ac9 View commit details

Commits on Dec 26, 2018

  1. Copy the full SHA
    c536f13 View commit details
Showing with 41 additions and 12 deletions.
  1. +1 −0 CHANGELOG.md
  2. +2 −1 Cmdline/Action/Update.cs
  3. +11 −9 Core/Net/Repo.cs
  4. +26 −1 GUI/MainModList.cs
  5. +1 −1 GUI/MainRepo.cs
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Confirm quit with pending change set or conflicts (#2599 by: HebaruSan; reviewed: politas)
- [Multiple] Warn before launching KSP with installed incompatible modules (#2601 by: HebaruSan; reviewed: politas)
- [GUI] Allow selection of text in mod info panel (#2610 by: DasSkelett; reviewed: HebaruSan)
- [Multiple] Show progress bar while loading registry (#2617 by: HebaruSan; reviewed: politas)

### Bugfixes
- [GUI] Fix platform checks and crash on Mac OS X (#2600 by: HebaruSan; reviewed: politas)
3 changes: 2 additions & 1 deletion Cmdline/Action/Update.cs
Original file line number Diff line number Diff line change
@@ -153,7 +153,8 @@ private void UpdateRepository(CKAN.KSP ksp, string repository = null)
? CKAN.Repo.UpdateAllRepositories(registry_manager, ksp, manager.Cache, user)
: CKAN.Repo.Update(registry_manager, ksp, user, repository);

user.RaiseMessage("Updated information on {0} available modules", updated);
user.RaiseMessage("Updated information on {0} available modules",
registry_manager.registry.Available(ksp.VersionCriteria()).Count);
}
}
}
20 changes: 11 additions & 9 deletions Core/Net/Repo.cs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ public static class Repo
/// Optionally takes a URL to the zipfile repo to download.
/// Returns the number of unique modules updated.
/// </summary>
public static int UpdateAllRepositories(RegistryManager registry_manager, KSP ksp, NetModuleCache cache, IUser user)
public static bool UpdateAllRepositories(RegistryManager registry_manager, KSP ksp, NetModuleCache cache, IUser user)
{
SortedDictionary<string, Repository> sortedRepositories = registry_manager.registry.Repositories;
List<CkanModule> allAvail = new List<CkanModule>();
@@ -42,7 +42,7 @@ public static int UpdateAllRepositories(RegistryManager registry_manager, KSP ks
{
// Report failure if any repo fails, rather than losing half the list.
// UpdateRegistry will have alerted the user to specific errors already.
return 0;
return false;
}
else
{
@@ -66,13 +66,14 @@ public static int UpdateAllRepositories(RegistryManager registry_manager, KSP ks
HandleModuleChanges(metadataChanges, user, ksp, cache);
}

// Return how many we got!
return registry_manager.registry.Available(ksp.VersionCriteria()).Count;
// Registry.Available is slow, just return success,
// caller can check it if it's really needed
return true;
}
else
{
// Return failure
return 0;
return false;
}
}

@@ -372,7 +373,7 @@ private static bool RelationshipsAreEquivalent(List<RelationshipDescriptor> a, L
/// <returns>
/// Number of modules found in repo
/// </returns>
public static int Update(RegistryManager registry_manager, KSP ksp, IUser user, string repo = null)
public static bool Update(RegistryManager registry_manager, KSP ksp, IUser user, string repo = null)
{
if (repo == null)
{
@@ -383,7 +384,7 @@ public static int Update(RegistryManager registry_manager, KSP ksp, IUser user,
}

// Same as above, just with a Uri instead of string for the repo
public static int Update(RegistryManager registry_manager, KSP ksp, IUser user, Uri repo = null)
public static bool Update(RegistryManager registry_manager, KSP ksp, IUser user, Uri repo = null)
{
// Use our default repo, unless we've been told otherwise.
if (repo == null)
@@ -405,8 +406,9 @@ public static int Update(RegistryManager registry_manager, KSP ksp, IUser user,

ShowUserInconsistencies(registry_manager.registry, user);

// Return how many we got!
return registry_manager.registry.Available(ksp.VersionCriteria()).Count;
// Registry.Available is slow, just return success,
// caller can check it if it's really needed
return true;
}

/// <summary>
27 changes: 26 additions & 1 deletion GUI/MainModList.cs
Original file line number Diff line number Diff line change
@@ -141,32 +141,47 @@ private void _UpdateFilters()

public void UpdateModsList(Boolean repo_updated = false, IEnumerable<ModChange> mc = null)
{
Util.Invoke(this, () => _UpdateModsList(repo_updated, mc ?? new List<ModChange>()));
// Run the update in the background so the UI thread can appear alive
Task.Factory.StartNew(() =>
_UpdateModsList(repo_updated, mc ?? new List<ModChange>())
);
}

private void _UpdateModsList(bool repo_updated, IEnumerable<ModChange> mc)
{
log.Info("Updating the mod list");

ResetProgress();
tabController.RenameTab("WaitTabPage", "Loading modules");
ShowWaitDialog(false);
tabController.SetTabLock(true);
SwitchEnabledState();
ClearLog();

AddLogMessage("Loading registry...");
KspVersionCriteria versionCriteria = CurrentInstance.VersionCriteria();
IRegistryQuerier registry = RegistryManager.Instance(CurrentInstance).registry;

AddLogMessage("Loading installed modules...");
var gui_mods = new HashSet<GUIMod>();
gui_mods.UnionWith(
registry.InstalledModules
.Select(instMod => new GUIMod(instMod, registry, versionCriteria))
);
AddLogMessage("Loading available modules...");
gui_mods.UnionWith(
registry.Available(versionCriteria)
.Select(m => new GUIMod(m, registry, versionCriteria))
);
AddLogMessage("Loading incompatible modules...");
gui_mods.UnionWith(
registry.Incompatible(versionCriteria)
.Select(m => new GUIMod(m, registry, versionCriteria, true))
);

if (mc != null)
{
AddLogMessage("Restoring change set...");
foreach (ModChange change in mc)
{
// Propagate IsInstallChecked and IsUpgradeChecked to the next generation
@@ -176,6 +191,7 @@ private void _UpdateModsList(bool repo_updated, IEnumerable<ModChange> mc)
}
}

AddLogMessage("Preserving new flags...");
var old_modules = mainModList.Modules.ToDictionary(m => m, m => m.IsIncompatible);
if (repo_updated)
{
@@ -207,11 +223,13 @@ private void _UpdateModsList(bool repo_updated, IEnumerable<ModChange> mc)
}
}

AddLogMessage("Populating mod list...");
// Update our mod listing
mainModList.ConstructModList(gui_mods.ToList(), mc, configuration.HideEpochs, configuration.HideV);
mainModList.Modules = new ReadOnlyCollection<GUIMod>(
mainModList.full_list_of_mod_rows.Values.Select(row => row.Tag as GUIMod).ToList());

AddLogMessage("Updating filters...");
//TODO Consider using smart enumeration pattern so stuff like this is easier
FilterToolButton.DropDownItems[0].Text = String.Format("Compatible ({0})",
mainModList.CountModsByFilter(GUIModFilter.Compatible));
@@ -232,7 +250,14 @@ private void _UpdateModsList(bool repo_updated, IEnumerable<ModChange> mc)
var has_any_updates = gui_mods.Any(mod => mod.HasUpdate);
UpdateAllToolButton.Enabled = has_any_updates;
UpdateFilters(this);

AddLogMessage("Updating tray...");
UpdateTrayInfo();

HideWaitDialog(true);
tabController.HideTab("WaitTabPage");
tabController.SetTabLock(false);
SwitchEnabledState();
}

public void MarkModForInstall(string identifier, bool uncheck = false)
2 changes: 1 addition & 1 deletion GUI/MainRepo.cs
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ private void UpdateRepo(object sender, DoWorkEventArgs e)

private void PostUpdateRepo(object sender, RunWorkerCompletedEventArgs e)
{
if ((e.Result as int? ?? 0) > 0)
if (e.Result as bool? ?? true)
{
UpdateModsList(true, ChangeSet);
AddStatusMessage("Repositories successfully updated.");