mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-20 14:57:45 +01:00
feat: delete old versions of plugins before load
This commit is contained in:
parent
721527dd11
commit
62bd3af459
2 changed files with 59 additions and 26 deletions
|
|
@ -241,5 +241,36 @@ namespace Dalamud.Plugin
|
|||
|
||||
return (!hasError, updatedList);
|
||||
}
|
||||
|
||||
public void CleanupPlugins() {
|
||||
try
|
||||
{
|
||||
var pluginsDirectory = new DirectoryInfo(this.pluginDirectory);
|
||||
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(x => int.Parse(x.Name.Replace(".", ""))).ToArray();
|
||||
for (var i = 0; i < sortedVersions.Length - 1; i++) {
|
||||
Log.Information("[PLUGINR] Trying to delete old {0} at ", installed.Name, sortedVersions[i].FullName);
|
||||
try {
|
||||
sortedVersions[i].Delete(true);
|
||||
} catch (Exception ex) {
|
||||
Log.Error(ex, "[PLUGINR] Could not delete old version");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "[PLUGINR] Plugin cleanup failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue