mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Workshop - Fix installing new versions of profiles
This commit is contained in:
parent
648b7765ef
commit
00948de9d6
@ -120,14 +120,6 @@ public interface IProfileService : IArtemisService
|
|||||||
Task<ProfileConfiguration> ImportProfile(Stream archiveStream, ProfileCategory category, bool makeUnique, bool markAsFreshImport, string? nameAffix = "imported",
|
Task<ProfileConfiguration> ImportProfile(Stream archiveStream, ProfileCategory category, bool makeUnique, bool markAsFreshImport, string? nameAffix = "imported",
|
||||||
ProfileConfiguration? target = null);
|
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>
|
/// <summary>
|
||||||
/// Adapts a given profile to the currently active devices.
|
/// Adapts a given profile to the currently active devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -434,18 +434,6 @@ internal class ProfileService : IProfileService
|
|||||||
return profileConfiguration;
|
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 />
|
/// <inheritdoc />
|
||||||
public void AdaptProfile(Profile profile)
|
public void AdaptProfile(Profile profile)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -42,11 +42,16 @@ public class ProfileEntryInstallationHandler : IEntryInstallationHandler
|
|||||||
ProfileConfiguration? existing = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == profileId);
|
ProfileConfiguration? existing = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == profileId);
|
||||||
if (existing != null)
|
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);
|
installedEntry.SetMetadata("ProfileId", overwritten.ProfileId);
|
||||||
|
|
||||||
// Update the release and return the profile configuration
|
|
||||||
UpdateRelease(installedEntry, release);
|
UpdateRelease(installedEntry, release);
|
||||||
|
|
||||||
|
// With everything updated, remove the old profile
|
||||||
|
_profileService.RemoveProfileConfiguration(existing);
|
||||||
|
|
||||||
return EntryInstallResult.FromSuccess(installedEntry);
|
return EntryInstallResult.FromSuccess(installedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user