feat(PluginRepo): delete empty installed folder when no versions (closes #339)

This commit is contained in:
goat 2021-04-29 12:47:02 +02:00
parent 05347e65b1
commit 287cc0b84f
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -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}");
}
}
}
}
}