mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-02-04 02:43:32 +00:00
Hotfix workshop auto-update
This commit is contained in:
parent
4b58485956
commit
7c7d91eda9
@ -26,9 +26,8 @@ public class WorkshopService : IWorkshopService
|
|||||||
private readonly IWorkshopClient _workshopClient;
|
private readonly IWorkshopClient _workshopClient;
|
||||||
private readonly PluginSetting<bool> _migratedBuiltInPlugins;
|
private readonly PluginSetting<bool> _migratedBuiltInPlugins;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
private bool _mutating;
|
||||||
|
|
||||||
public WorkshopService(ILogger logger,
|
public WorkshopService(ILogger logger,
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
@ -173,27 +172,45 @@ public class WorkshopService : IWorkshopService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<EntryInstallResult> InstallEntry(IEntrySummary entry, IRelease release, Progress<StreamProgress> progress, CancellationToken cancellationToken)
|
public async Task<EntryInstallResult> InstallEntry(IEntrySummary entry, IRelease release, Progress<StreamProgress> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
IEntryInstallationHandler handler = _factory.CreateHandler(entry.EntryType);
|
_mutating = true;
|
||||||
EntryInstallResult result = await handler.InstallAsync(entry, release, progress, cancellationToken);
|
|
||||||
if (result.IsSuccess && result.Entry != null)
|
|
||||||
OnEntryInstalled?.Invoke(this, result.Entry);
|
|
||||||
else
|
|
||||||
_logger.Warning("Failed to install entry {Entry}: {Message}", entry, result.Message);
|
|
||||||
|
|
||||||
return result;
|
try
|
||||||
|
{
|
||||||
|
IEntryInstallationHandler handler = _factory.CreateHandler(entry.EntryType);
|
||||||
|
EntryInstallResult result = await handler.InstallAsync(entry, release, progress, cancellationToken);
|
||||||
|
if (result.IsSuccess && result.Entry != null)
|
||||||
|
OnEntryInstalled?.Invoke(this, result.Entry);
|
||||||
|
else
|
||||||
|
_logger.Warning("Failed to install entry {Entry}: {Message}", entry, result.Message);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_mutating = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<EntryUninstallResult> UninstallEntry(InstalledEntry installedEntry, CancellationToken cancellationToken)
|
public async Task<EntryUninstallResult> UninstallEntry(InstalledEntry installedEntry, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
IEntryInstallationHandler handler = _factory.CreateHandler(installedEntry.EntryType);
|
_mutating = true;
|
||||||
EntryUninstallResult result = await handler.UninstallAsync(installedEntry, cancellationToken);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
OnEntryUninstalled?.Invoke(this, installedEntry);
|
|
||||||
else
|
|
||||||
_logger.Warning("Failed to uninstall entry {EntryId}: {Message}", installedEntry.Id, result.Message);
|
|
||||||
|
|
||||||
return result;
|
try
|
||||||
|
{
|
||||||
|
IEntryInstallationHandler handler = _factory.CreateHandler(installedEntry.EntryType);
|
||||||
|
EntryUninstallResult result = await handler.UninstallAsync(installedEntry, cancellationToken);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
OnEntryUninstalled?.Invoke(this, installedEntry);
|
||||||
|
else
|
||||||
|
_logger.Warning("Failed to uninstall entry {EntryId}: {Message}", installedEntry.Id, result.Message);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_mutating = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -317,15 +334,27 @@ public class WorkshopService : IWorkshopService
|
|||||||
if (_migratedBuiltInPlugins.Value)
|
if (_migratedBuiltInPlugins.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MigratingBuildInPlugins?.Invoke(this, EventArgs.Empty);
|
_mutating = true;
|
||||||
|
|
||||||
bool migrated = await BuiltInPluginsMigrator.Migrate(this, _workshopClient, _logger, _pluginRepository);
|
try
|
||||||
_migratedBuiltInPlugins.Value = migrated;
|
{
|
||||||
_migratedBuiltInPlugins.Save();
|
MigratingBuildInPlugins?.Invoke(this, EventArgs.Empty);
|
||||||
|
|
||||||
|
bool migrated = await BuiltInPluginsMigrator.Migrate(this, _workshopClient, _logger, _pluginRepository);
|
||||||
|
_migratedBuiltInPlugins.Value = migrated;
|
||||||
|
_migratedBuiltInPlugins.Save();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_mutating = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProfileServiceOnProfileRemoved(object? sender, ProfileConfigurationEventArgs e)
|
private void ProfileServiceOnProfileRemoved(object? sender, ProfileConfigurationEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_mutating)
|
||||||
|
return;
|
||||||
|
|
||||||
InstalledEntry? entry = GetInstalledEntryByProfile(e.ProfileConfiguration);
|
InstalledEntry? entry = GetInstalledEntryByProfile(e.ProfileConfiguration);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return;
|
return;
|
||||||
@ -336,6 +365,9 @@ public class WorkshopService : IWorkshopService
|
|||||||
|
|
||||||
private void PluginManagementServiceOnPluginRemoved(object? sender, PluginEventArgs e)
|
private void PluginManagementServiceOnPluginRemoved(object? sender, PluginEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_mutating)
|
||||||
|
return;
|
||||||
|
|
||||||
InstalledEntry? entry = GetInstalledEntryByPlugin(e.Plugin);
|
InstalledEntry? entry = GetInstalledEntryByPlugin(e.Plugin);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user