Rework plugin deletion + misc (#927)

* fix: stuck overlay on errors

* feat: delete old plugin versions

* feat: ignore error tag when outdated, banned, or orphaned

* feat: rework plugin deletion
This commit is contained in:
Aireil 2022-07-23 15:47:24 +02:00 committed by GitHub
parent 62831f8d1e
commit 1574ef7c33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 19 deletions

View file

@ -848,10 +848,17 @@ internal partial class PluginManager : IDisposable, IServiceType
}
else
{
foreach (var versionDir in versionDirs)
for (var i = 0; i < versionDirs.Length; i++)
{
var versionDir = versionDirs[i];
try
{
if (i != 0)
{
Log.Information($"Old version: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
continue;
}
var dllFile = new FileInfo(Path.Combine(versionDir.FullName, $"{pluginDir.Name}.dll"));
if (!dllFile.Exists)
{
@ -865,6 +872,21 @@ internal partial class PluginManager : IDisposable, IServiceType
{
Log.Information($"Missing manifest: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
continue;
}
if (manifestFile.Length == 0)
{
Log.Information($"Manifest empty: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
continue;
}
var manifest = LocalPluginManifest.Load(manifestFile);
if (manifest.ScheduledForDeletion)
{
Log.Information($"Scheduled deletion: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
}
}
catch (Exception ex)
@ -902,6 +924,9 @@ internal partial class PluginManager : IDisposable, IServiceType
if (plugin.InstalledPlugin.Manifest.Disabled && ignoreDisabled)
continue;
if (plugin.InstalledPlugin.Manifest.ScheduledForDeletion)
continue;
var result = await this.UpdateSinglePluginAsync(plugin, false, dryRun);
if (result != null)
updatedList.Add(result);