Skip to content

Commit d063f13

Browse files
committed
Hotfix - Auto-enable plugins after updating them
1 parent 7c7d91e commit d063f13

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/Artemis.UI/Services/Updating/WorkshopUpdateService.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ public class WorkshopUpdateService : IWorkshopUpdateService
2020
private readonly ILogger _logger;
2121
private readonly IWorkshopClient _client;
2222
private readonly IWorkshopService _workshopService;
23+
private readonly IPluginManagementService _pluginManagementService;
2324
private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider;
2425
private readonly PluginSetting<bool> _showNotifications;
2526

26-
public WorkshopUpdateService(ILogger logger, IWorkshopClient client, IWorkshopService workshopService, ISettingsService settingsService,
27+
public WorkshopUpdateService(ILogger logger,
28+
IWorkshopClient client,
29+
IWorkshopService workshopService,
30+
ISettingsService settingsService,
31+
IPluginManagementService pluginManagementService,
2732
Lazy<IUpdateNotificationProvider> updateNotificationProvider)
2833
{
2934
_logger = logger;
3035
_client = client;
3136
_workshopService = workshopService;
37+
_pluginManagementService = pluginManagementService;
3238
_updateNotificationProvider = updateNotificationProvider;
3339
_showNotifications = settingsService.GetSetting("Workshop.ShowNotifications", true);
3440
}
@@ -88,6 +94,18 @@ public async Task<bool> AutoUpdateEntry(InstalledEntry installedEntry)
8894
else
8995
_logger.Warning("Auto-update failed for entry {Entry}: {Message}", entry, updateResult.Message);
9096

97+
if (!updateResult.IsSuccess || updateResult.Installed is not Plugin {IsEnabled: false} updatedPlugin)
98+
return updateResult.IsSuccess;
99+
100+
try
101+
{
102+
_pluginManagementService.EnablePlugin(updatedPlugin, true, true);
103+
}
104+
catch (Exception e)
105+
{
106+
_logger.Warning(e, "Failed to auto-enable updated plugin {Plugin}", updatedPlugin);
107+
}
108+
91109
return updateResult.IsSuccess;
92110
}
93111
catch (Exception e)

src/Artemis.WebClient.Workshop/Handlers/InstallationHandlers/Implementations/PluginEntryInstallationHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ public async Task<EntryInstallResult> InstallAsync(IEntrySummary entry, IRelease
101101
{
102102
// ignored, will get cleaned up as an orphaned file
103103
}
104-
105-
if (installedEntry.Entity.Id != Guid.Empty)
106-
_workshopService.RemoveInstalledEntry(installedEntry);
104+
107105
return EntryInstallResult.FromException(e);
108106
}
109107

0 commit comments

Comments
 (0)