diff --git a/src/KKManager.Core/Data/Plugins/PluginLoader.cs b/src/KKManager.Core/Data/Plugins/PluginLoader.cs
index bdfb937..9129552 100644
--- a/src/KKManager.Core/Data/Plugins/PluginLoader.cs
+++ b/src/KKManager.Core/Data/Plugins/PluginLoader.cs
@@ -53,6 +53,8 @@ public static void CancelReload()
/// Directory containing the plugins to gather info from. Usually BepInEx directory inside game root.
private static void TryLoadPlugins(string pluginDirectory, ReplaySubject subject)
{
+ Console.WriteLine("Start loading plugins");
+
_cancelSource?.Dispose();
_cancelSource = new CancellationTokenSource();
var token = _cancelSource.Token;
@@ -99,38 +101,24 @@ void ReadPluginsAsync()
Console.WriteLine($"Failed to load plugin from \"{file}\" with error: {ex}");
}
}
-
- subject.OnCompleted();
- Console.WriteLine("Finished loading plugins");
- }
- catch (OperationCanceledException ex)
- {
- subject.OnCompleted();
- }
- catch (UnauthorizedAccessException ex)
- {
- MessageBox.Show("Could not load information about plugins because access to the plugins folder was denied. Check the permissions of your plugins folder and try again.\n\n" + ex.Message,
- "Load plugins", MessageBoxButtons.OK, MessageBoxIcon.Warning);
-
- Console.WriteLine(ex);
- subject.OnError(ex);
}
- catch (SecurityException ex)
+ catch (OperationCanceledException)
{
- MessageBox.Show("Could not load information about plugins because access to the plugins folder was denied. Check the permissions of your plugins folder and try again.\n\n" + ex.Message,
- "Load plugins", MessageBoxButtons.OK, MessageBoxIcon.Warning);
-
- Console.WriteLine(ex);
- subject.OnError(ex);
}
catch (Exception ex)
{
- Console.WriteLine(ex);
+ if (ex is SecurityException || ex is UnauthorizedAccessException)
+ MessageBox.Show("Could not load information about plugins because access to the plugins folder was denied. Check the permissions of your plugins folder and try again.\n\n" + ex.Message,
+ "Load plugins", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+
+ Console.WriteLine("Crash when loading plugins: " + ex);
subject.OnError(ex);
}
finally
{
_isUpdating = false;
+ Console.WriteLine("Finished loading plugins");
+ subject.OnCompleted();
}
}
diff --git a/src/KKManager.Core/Data/Zipmods/SideloaderModLoader.cs b/src/KKManager.Core/Data/Zipmods/SideloaderModLoader.cs
index 12fcfa6..39306b4 100644
--- a/src/KKManager.Core/Data/Zipmods/SideloaderModLoader.cs
+++ b/src/KKManager.Core/Data/Zipmods/SideloaderModLoader.cs
@@ -4,8 +4,10 @@
using System.IO;
using System.Linq;
using System.Reactive.Subjects;
+using System.Security;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Forms;
using System.Xml.Linq;
using KKManager.Functions;
using KKManager.Util;
@@ -53,6 +55,8 @@ public static void CancelReload()
/// Where to search
private static void TryReadSideloaderMods(string modDirectory, ReplaySubject subject, SearchOption searchOption = SearchOption.AllDirectories)
{
+ Console.WriteLine("Start loading zipmods");
+
_cancelSource?.Dispose();
_cancelSource = new CancellationTokenSource();
var token = _cancelSource.Token;
@@ -88,25 +92,27 @@ void ReadSideloaderModsAsync()
}
catch (Exception ex)
{
- Console.WriteLine($"Failed to load mod from \"{file}\" with error: {ex}");
+ Console.WriteLine($"Failed to load zipmod from \"{file}\" with error: {ex}");
}
}
-
- subject.OnCompleted();
- Console.WriteLine("Finished loading zipmods");
}
catch (OperationCanceledException)
{
- subject.OnCompleted();
}
catch (Exception ex)
{
- Console.WriteLine(ex);
+ if (ex is SecurityException || ex is UnauthorizedAccessException)
+ MessageBox.Show("Could not load information about zipmods because access to the plugins folder was denied. Check the permissions of your mods folder and try again.\n\n" + ex.Message,
+ "Load zipmods", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+
+ Console.WriteLine("Crash when loading zipmods: " + ex);
subject.OnError(ex);
}
finally
{
_isUpdating = false;
+ Console.WriteLine("Finished loading zipmods");
+ subject.OnCompleted();
}
}