From 287cc0b84f2820bdfd55f4a639e937a461c22930 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Thu, 29 Apr 2021 12:47:02 +0200 Subject: [PATCH] feat(PluginRepo): delete empty installed folder when no versions (closes #339) --- Dalamud/Plugin/PluginRepository.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Dalamud/Plugin/PluginRepository.cs b/Dalamud/Plugin/PluginRepository.cs index 73fa9c725..2340b61ae 100644 --- a/Dalamud/Plugin/PluginRepository.cs +++ b/Dalamud/Plugin/PluginRepository.cs @@ -336,11 +336,6 @@ namespace Dalamud.Plugin foreach (var installed in pluginsDirectory.GetDirectories()) { var versions = installed.GetDirectories(); - if (versions.Length == 0) { - Log.Information("[PLUGINR] Has no versions: {0}", installed.FullName); - continue; - } - var sortedVersions = versions.OrderBy(dirInfo => { var success = Version.TryParse(dirInfo.Name, out Version version); if (!success) { Log.Debug("Unparseable version: {0}", dirInfo.Name); } @@ -381,6 +376,20 @@ namespace Dalamud.Plugin { Log.Error(ex, $"[PLUGINR] Could not clean up {version.FullName}"); } + + if (installed.GetDirectories().Length == 0) + { + Log.Information("[PLUGINR] Has no versions, cleaning up: {0}", installed.FullName); + + try + { + installed.Delete(); + } + catch (Exception ex) + { + Log.Error(ex, $"[PLUGINR] Could not clean up {installed.FullName}"); + } + } } } }