mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
fix: don't reenable updated plugins automatically
This commit is contained in:
parent
845a5908b2
commit
48fcebfe12
1 changed files with 28 additions and 8 deletions
|
|
@ -58,14 +58,15 @@ namespace Dalamud.Plugin
|
|||
}
|
||||
}
|
||||
|
||||
public bool InstallPlugin(PluginDefinition definition) {
|
||||
public bool InstallPlugin(PluginDefinition definition, bool enableAfterInstall = true) {
|
||||
try
|
||||
{
|
||||
var outputDir = new DirectoryInfo(Path.Combine(this.pluginDirectory, definition.InternalName, definition.AssemblyVersion));
|
||||
var dllFile = new FileInfo(Path.Combine(outputDir.FullName, $"{definition.InternalName}.dll"));
|
||||
var disabledFile = new FileInfo(Path.Combine(outputDir.FullName, ".disabled"));
|
||||
var wasDisabled = disabledFile.Exists;
|
||||
|
||||
if (dllFile.Exists)
|
||||
if (dllFile.Exists && enableAfterInstall)
|
||||
{
|
||||
if (disabledFile.Exists)
|
||||
disabledFile.Delete();
|
||||
|
|
@ -73,9 +74,17 @@ namespace Dalamud.Plugin
|
|||
return this.manager.LoadPluginFromAssembly(dllFile, false);
|
||||
}
|
||||
|
||||
if (outputDir.Exists)
|
||||
outputDir.Delete(true);
|
||||
outputDir.Create();
|
||||
if (dllFile.Exists && !enableAfterInstall) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (outputDir.Exists)
|
||||
outputDir.Delete(true);
|
||||
outputDir.Create();
|
||||
} catch {
|
||||
// ignored, since the plugin may be loaded already
|
||||
}
|
||||
|
||||
var path = Path.GetTempFileName();
|
||||
Log.Information("Downloading plugin to {0}", path);
|
||||
|
|
@ -86,6 +95,11 @@ namespace Dalamud.Plugin
|
|||
|
||||
ZipFile.ExtractToDirectory(path, outputDir.FullName);
|
||||
|
||||
if (wasDisabled || !enableAfterInstall) {
|
||||
disabledFile.Create();
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.manager.LoadPluginFromAssembly(dllFile, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -145,6 +159,12 @@ namespace Dalamud.Plugin
|
|||
|
||||
if (!dryRun)
|
||||
{
|
||||
var wasEnabled =
|
||||
this.manager.Plugins.Where(x => x.Definition != null).Any(
|
||||
x => x.Definition.InternalName == info.InternalName); ;
|
||||
|
||||
Log.Verbose("wasEnabled: {0}", wasEnabled);
|
||||
|
||||
// Try to disable plugin if it is loaded
|
||||
try
|
||||
{
|
||||
|
|
@ -153,7 +173,7 @@ namespace Dalamud.Plugin
|
|||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Plugin disable failed");
|
||||
hasError = true;
|
||||
//hasError = true;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -165,10 +185,10 @@ namespace Dalamud.Plugin
|
|||
disabledFile.Create();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.Error(ex, "Plugin disable failed");
|
||||
Log.Error(ex, "Plugin disable old versions failed");
|
||||
}
|
||||
|
||||
var installSuccess = InstallPlugin(remoteInfo);
|
||||
var installSuccess = InstallPlugin(remoteInfo, wasEnabled);
|
||||
|
||||
if (installSuccess)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue