1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Workshop - Fix installing new versions of profiles

This commit is contained in:
Robert 2024-07-02 22:34:25 +02:00
parent 648b7765ef
commit 00948de9d6
3 changed files with 8 additions and 23 deletions

View File

@ -120,14 +120,6 @@ public interface IProfileService : IArtemisService
Task<ProfileConfiguration> ImportProfile(Stream archiveStream, ProfileCategory category, bool makeUnique, bool markAsFreshImport, string? nameAffix = "imported",
ProfileConfiguration? target = null);
/// <summary>
/// Imports the provided ZIP archive stream into the provided profile configuration
/// </summary>
/// <param name="archiveStream">The zip archive containing the profile to import.</param>
/// <param name="profileConfiguration">The profile configuration to overwrite.</param>
/// <returns>The resulting profile configuration.</returns>
Task<ProfileConfiguration> OverwriteProfile(MemoryStream archiveStream, ProfileConfiguration profileConfiguration);
/// <summary>
/// Adapts a given profile to the currently active devices.
/// </summary>

View File

@ -434,18 +434,6 @@ internal class ProfileService : IProfileService
return profileConfiguration;
}
/// <inheritdoc />
public async Task<ProfileConfiguration> OverwriteProfile(MemoryStream archiveStream, ProfileConfiguration profileConfiguration)
{
ProfileConfiguration imported = await ImportProfile(archiveStream, profileConfiguration.Category, true, false, null, profileConfiguration);
imported.Name = profileConfiguration.Name;
RemoveProfileConfiguration(profileConfiguration);
SaveProfileCategory(imported.Category);
return imported;
}
/// <inheritdoc />
public void AdaptProfile(Profile profile)
{

View File

@ -42,11 +42,16 @@ public class ProfileEntryInstallationHandler : IEntryInstallationHandler
ProfileConfiguration? existing = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == profileId);
if (existing != null)
{
ProfileConfiguration overwritten = await _profileService.OverwriteProfile(stream, existing);
ProfileConfiguration overwritten = await _profileService.ImportProfile(stream, existing.Category, true, false, null, existing);
overwritten.Name = existing.Name;
// Update the release
installedEntry.SetMetadata("ProfileId", overwritten.ProfileId);
// Update the release and return the profile configuration
UpdateRelease(installedEntry, release);
// With everything updated, remove the old profile
_profileService.RemoveProfileConfiguration(existing);
return EntryInstallResult.FromSuccess(installedEntry);
}
}