From e12f1acacf2d52a8618548d7c0861368c9c06dd3 Mon Sep 17 00:00:00 2001 From: Auros Nexus Date: Wed, 23 Dec 2020 21:53:24 -0500 Subject: [PATCH] Update PluginManager.cs --- IPA.Loader/Loader/PluginManager.cs | 42 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 28f117f0..580ab1a6 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -351,17 +351,6 @@ namespace IPA.Loader if (!Directory.Exists(pluginDirectory)) return; - string cacheDir = Path.Combine(pluginDirectory, ".cache"); - - if (!Directory.Exists(cacheDir)) - { - Directory.CreateDirectory(cacheDir); - } - else - { - foreach (string plugin in Directory.GetFiles(cacheDir, "*")) - File.Delete(plugin); - } // initialize BSIPA plugins first _bsPlugins.AddRange(PluginLoader.LoadPlugins()); @@ -373,11 +362,28 @@ namespace IPA.Loader //Copy plugins to .cache string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll"); + + string cacheDir = Path.Combine(pluginDirectory, ".cache"); + bool exists = Directory.Exists(cacheDir); + + if (exists) + { + foreach (string plugin in Directory.GetFiles(cacheDir, "*")) + File.Delete(plugin); + } + foreach (string s in originalPlugins) { if (metadataPaths.Contains(s)) continue; if (ignoredPaths.Contains(s)) continue; if (disabledPaths.Contains(s)) continue; + + if (!exists) + { + Directory.CreateDirectory(cacheDir); + exists = true; + } + string pluginCopy = Path.Combine(cacheDir, Path.GetFileName(s)); #region Fix assemblies for refactor @@ -418,12 +424,16 @@ namespace IPA.Loader } //Load copied plugins - string[] copiedPlugins = Directory.GetFiles(cacheDir, "*.dll"); - foreach (string s in copiedPlugins) + + if (exists) { - var result = LoadPluginsFromFile(s); - if (result == null) continue; - _ipaPlugins.AddRange(result.NonNull()); + string[] copiedPlugins = Directory.GetFiles(cacheDir, "*.dll"); + foreach (string s in copiedPlugins) + { + var result = LoadPluginsFromFile(s); + if (result == null) continue; + _ipaPlugins.AddRange(result.NonNull()); + } } Logger.log.Info(exeName);