From fb84e4cf30f350f0fc647aa6a1b9af2210fdabfe Mon Sep 17 00:00:00 2001 From: Richard Lake Date: Fri, 19 Dec 2014 14:33:47 +1030 Subject: [PATCH 1/3] Run scan before install or update. Otherwise it is possible to get into a inconsistent state. For example if an auto detected dependency is removed. Closes #381 --- CKAN/CmdLine/Main.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CKAN/CmdLine/Main.cs b/CKAN/CmdLine/Main.cs index 55331e6b9e..630aa3722d 100644 --- a/CKAN/CmdLine/Main.cs +++ b/CKAN/CmdLine/Main.cs @@ -155,6 +155,7 @@ public static int Main(string[] args) return Available(manager.CurrentInstance, user); case "install": + Scan(manager.CurrentInstance); return Install((InstallOptions)cmdline.options, manager.CurrentInstance, user); case "scan": @@ -170,6 +171,7 @@ public static int Main(string[] args) return Remove((RemoveOptions)cmdline.options, manager.CurrentInstance, user); case "upgrade": + Scan(manager.CurrentInstance); var upgrade = new Upgrade(user); return upgrade.RunCommand(manager.CurrentInstance, cmdline.options); From 9f5f46d18749796ffab1c4a2eba4771595e74e9e Mon Sep 17 00:00:00 2001 From: Richard Lake Date: Fri, 19 Dec 2014 14:34:29 +1030 Subject: [PATCH 2/3] CmdLine upgrade checks for auto detected mods. Raise a nice error message instead of a null pointer exception. Close #605 --- CKAN/CmdLine/Action/Upgrade.cs | 9 +++++++++ CKAN/CmdLine/CmdLine.csproj | 1 + 2 files changed, 10 insertions(+) diff --git a/CKAN/CmdLine/Action/Upgrade.cs b/CKAN/CmdLine/Action/Upgrade.cs index 1882538f8d..843fbcd69d 100644 --- a/CKAN/CmdLine/Action/Upgrade.cs +++ b/CKAN/CmdLine/Action/Upgrade.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; namespace CKAN.CmdLine @@ -60,6 +61,14 @@ public int RunCommand(CKAN.KSP ksp, object raw_options) } + var auto_detected_modules = to_upgrade.Where(module => ksp.Registry.IsAutodetected(module.identifier)).ToList(); + foreach (var module in auto_detected_modules.Select(mod => mod.identifier)) + { + User.RaiseMessage("Cannot upgrade {0} as it was not installed by CKAN. \n Please remove manually before trying again", module); + } + //Exit if any are auto_detected + if (auto_detected_modules.Any()) return Exit.ERROR; + User.RaiseMessage("\nUpgrading modules...\n"); // TODO: These instances all need to go. ModuleInstaller.GetInstance(ksp, User).Upgrade(to_upgrade,new NetAsyncDownloader(User)); diff --git a/CKAN/CmdLine/CmdLine.csproj b/CKAN/CmdLine/CmdLine.csproj index f3bbcae254..51d0f4cdc2 100644 --- a/CKAN/CmdLine/CmdLine.csproj +++ b/CKAN/CmdLine/CmdLine.csproj @@ -28,6 +28,7 @@ ..\packages\CommandLineParser.1.9.71\lib\net40\CommandLine.dll + From 64a9adddcca597efa19c127bdef0a1a1f86d735c Mon Sep 17 00:00:00 2001 From: Richard Lake Date: Fri, 19 Dec 2014 15:50:04 +1030 Subject: [PATCH 3/3] Fix spurious windows.forms reference. It was coming from the existence of a GUIMod extension method in a namespace with a using system.windows.forms. --- CKAN/CmdLine/CmdLine.csproj | 1 - CKAN/GUI/Util.cs | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CKAN/CmdLine/CmdLine.csproj b/CKAN/CmdLine/CmdLine.csproj index 51d0f4cdc2..f3bbcae254 100644 --- a/CKAN/CmdLine/CmdLine.csproj +++ b/CKAN/CmdLine/CmdLine.csproj @@ -28,7 +28,6 @@ ..\packages\CommandLineParser.1.9.71\lib\net40\CommandLine.dll - diff --git a/CKAN/GUI/Util.cs b/CKAN/GUI/Util.cs index fa6a92c204..4b6108c5e7 100644 --- a/CKAN/GUI/Util.cs +++ b/CKAN/GUI/Util.cs @@ -1,13 +1,14 @@ using System; -using System.Runtime.InteropServices; -using System.Windows.Forms; + namespace CKAN { + using System.Runtime.InteropServices; + using System.Windows.Forms; public static class Util { - + public static bool IsLinux { get @@ -75,12 +76,17 @@ public static void HideConsoleWindow() ShowWindow(GetConsoleWindow(), 0); } } + } +} - +namespace CKAN +{ + public static class UtilWithoutWinForm + { public static bool IsInstallable(this GUIMod mod) { + return !(mod == null || mod.IsAutodetected || mod.IsIncompatible); } - } - + } }