mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 15:27:43 +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
|
|
@ -90,30 +90,27 @@ namespace Dalamud {
|
||||||
this.WinSock2 = new WinSockHandlers();
|
this.WinSock2 = new WinSockHandlers();
|
||||||
|
|
||||||
AssetManager.EnsureAssets(this.baseDirectory).ContinueWith(async task => {
|
AssetManager.EnsureAssets(this.baseDirectory).ContinueWith(async task => {
|
||||||
if (task.IsCanceled || task.IsFaulted) {
|
if (task.IsCanceled || task.IsFaulted) throw new Exception("Could not ensure assets.", task.Exception);
|
||||||
throw new Exception("Could not ensure assets.", task.Exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.LocalizationManager = new Localization(this.StartInfo.WorkingDirectory);
|
this.LocalizationManager = new Localization(this.StartInfo.WorkingDirectory);
|
||||||
if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) {
|
if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride))
|
||||||
this.LocalizationManager.SetupWithLangCode(this.Configuration.LanguageOverride);
|
this.LocalizationManager.SetupWithLangCode(this.Configuration.LanguageOverride);
|
||||||
} else {
|
else
|
||||||
this.LocalizationManager.SetupWithUiCulture();
|
this.LocalizationManager.SetupWithUiCulture();
|
||||||
}
|
|
||||||
|
|
||||||
var pluginDir = this.StartInfo.PluginDirectory;
|
var pluginDir = this.StartInfo.PluginDirectory;
|
||||||
if (this.Configuration.DoPluginTest)
|
if (this.Configuration.DoPluginTest)
|
||||||
pluginDir = Path.Combine(pluginDir, "..", "testPlugins");
|
pluginDir = Path.Combine(pluginDir, "..", "testPlugins");
|
||||||
|
|
||||||
this.PluginRepository = new PluginRepository(this, pluginDir, this.StartInfo.GameVersion);
|
PluginRepository = new PluginRepository(this, pluginDir, this.StartInfo.GameVersion);
|
||||||
|
|
||||||
if (Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") != "True") {
|
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false")) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.InterfaceManager = new InterfaceManager(this, this.SigScanner);
|
InterfaceManager = new InterfaceManager(this, this.SigScanner);
|
||||||
this.InterfaceManager.OnDraw += BuildDalamudUi;
|
InterfaceManager.OnDraw += BuildDalamudUi;
|
||||||
|
|
||||||
this.InterfaceManager.Enable();
|
InterfaceManager.Enable();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -121,29 +118,34 @@ namespace Dalamud {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Data = new DataManager(this.StartInfo.Language);
|
Data = new DataManager(this.StartInfo.Language);
|
||||||
await this.Data.Initialize(this.baseDirectory);
|
await Data.Initialize(this.baseDirectory);
|
||||||
|
|
||||||
SeStringManager = new SeStringManager(Data);
|
SeStringManager = new SeStringManager(Data);
|
||||||
|
|
||||||
this.NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection);
|
NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection);
|
||||||
|
|
||||||
// Initialize managers. Basically handlers for the logic
|
// Initialize managers. Basically handlers for the logic
|
||||||
this.CommandManager = new CommandManager(this, info.Language);
|
CommandManager = new CommandManager(this, info.Language);
|
||||||
SetupCommands();
|
SetupCommands();
|
||||||
|
|
||||||
this.ChatHandlers = new ChatHandlers(this);
|
ChatHandlers = new ChatHandlers(this);
|
||||||
// Discord Bot Manager
|
// Discord Bot Manager
|
||||||
this.BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig);
|
BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig);
|
||||||
this.BotManager.Start();
|
BotManager.Start();
|
||||||
|
|
||||||
try {
|
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) {
|
||||||
this.PluginManager = new PluginManager(this, pluginDir, this.StartInfo.DefaultPluginDirectory);
|
try
|
||||||
this.PluginManager.LoadPlugins();
|
{
|
||||||
}
|
PluginRepository.CleanupPlugins();
|
||||||
catch (Exception ex)
|
|
||||||
{
|
PluginManager = new PluginManager(this, pluginDir, this.StartInfo.DefaultPluginDirectory);
|
||||||
Log.Error(ex, "Plugin load failed.");
|
PluginManager.LoadPlugins();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Plugin load failed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Framework.Enable();
|
this.Framework.Enable();
|
||||||
|
|
|
||||||
|
|
@ -241,5 +241,36 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
return (!hasError, updatedList);
|
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