V3 configuration migration no longer supported, you had enough time to upgrade
This commit is contained in:
@@ -14,7 +14,7 @@ internal static class V3ProfileToV4Converter
|
|||||||
var profile = new Profile
|
var profile = new Profile
|
||||||
{
|
{
|
||||||
Name = $"{v3Profile.ProfileName} - {v3Profile.CharacterName}",
|
Name = $"{v3Profile.ProfileName} - {v3Profile.CharacterName}",
|
||||||
//CharacterName = v3Profile.CharacterName, //todo
|
//CharacterName = v3Profile.CharacterName, //no longer supported
|
||||||
CreationDate = v3Profile.CreationDate,
|
CreationDate = v3Profile.CreationDate,
|
||||||
ModifiedDate = DateTimeOffset.UtcNow,
|
ModifiedDate = DateTimeOffset.UtcNow,
|
||||||
Enabled = v3Profile.Enabled,
|
Enabled = v3Profile.Enabled,
|
||||||
|
|||||||
@@ -44,74 +44,22 @@ public class ConfigurationMigrator
|
|||||||
if (configVersion >= Constants.ConfigurationVersion)
|
if (configVersion >= Constants.ConfigurationVersion)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//V3 migration code
|
//We no longer support migrations of any versions < 4
|
||||||
if (configVersion < 3)
|
if (configVersion < 3)
|
||||||
{
|
{
|
||||||
_messageService.NotificationMessage($"Unable to migrate your Customize+ configuration because it is too old. Manually install latest version of Customize+ 1.x to migrate your configuration to supported version first.", NotificationType.Error);
|
_messageService.NotificationMessage($"Unable to migrate your Customize+ configuration because it is too old. Manually install latest version of Customize+ 1.x to migrate your configuration to supported version first.", NotificationType.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MigrateV3ToV4();
|
if (configVersion < 4)
|
||||||
// /V3 migration code
|
{
|
||||||
|
_messageService.NotificationMessage($"Unable to migrate your Customize+ configuration because it is too old. Manually install Customize+ 2.0.6.5 to migrate your configuration to supported version first.", NotificationType.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
config.Version = Constants.ConfigurationVersion;
|
config.Version = Constants.ConfigurationVersion;
|
||||||
_saveService.ImmediateSave(config);
|
_saveService.ImmediateSave(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MigrateV3ToV4()
|
|
||||||
{
|
|
||||||
_backupService.CreateV3Backup();
|
|
||||||
|
|
||||||
//I'm sorry, I'm too lazy so v3's enable root position setting is not getting migrated
|
|
||||||
|
|
||||||
bool anyMigrationFailures = false;
|
|
||||||
|
|
||||||
var usedGuids = new HashSet<Guid>();
|
|
||||||
foreach (var file in Directory.EnumerateFiles(_saveService.FileNames.ConfigDirectory, "*.profile", SearchOption.TopDirectoryOnly))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.Debug($"Migrating v3 profile {file}");
|
|
||||||
|
|
||||||
var legacyProfile = JsonConvert.DeserializeObject<Version3Profile>(File.ReadAllText(file));
|
|
||||||
if (legacyProfile == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
_logger.Debug($"v3 profile {file} loaded as {legacyProfile.ProfileName}");
|
|
||||||
|
|
||||||
(var profile, var template) = V3ProfileToV4Converter.Convert(legacyProfile);
|
|
||||||
|
|
||||||
//regenerate guids just to be safe
|
|
||||||
do
|
|
||||||
{
|
|
||||||
profile.UniqueId = Guid.NewGuid();
|
|
||||||
}
|
|
||||||
while (profile.UniqueId == Guid.Empty || usedGuids.Contains(profile.UniqueId));
|
|
||||||
usedGuids.Add(profile.UniqueId);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
template.UniqueId = Guid.NewGuid();
|
|
||||||
}
|
|
||||||
while (template.UniqueId == Guid.Empty || usedGuids.Contains(template.UniqueId));
|
|
||||||
usedGuids.Add(template.UniqueId);
|
|
||||||
|
|
||||||
_saveService.ImmediateSaveSync(template);
|
|
||||||
_saveService.ImmediateSaveSync(profile);
|
|
||||||
|
|
||||||
_logger.Debug($"Migrated v3 profile {legacyProfile.ProfileName} to profile {profile.UniqueId} and template {template.UniqueId}");
|
|
||||||
File.Delete(file);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
anyMigrationFailures = true;
|
|
||||||
_logger.Error($"Error while migrating {file}: {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anyMigrationFailures)
|
|
||||||
_messageService.NotificationMessage($"Some of your Customize+ profiles failed to migrate correctly.\nDetails have been printed to Dalamud log (/xllog in chat).", NotificationType.Error);
|
|
||||||
|
|
||||||
_reloadEvent.Invoke(ReloadEvent.Type.ReloadAll);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
using CustomizePlus.Core.Services;
|
|
||||||
using OtterGui.Log;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CustomizePlus.Configuration.Services.Temporary;
|
|
||||||
|
|
||||||
//V3 has bug when it doesn't create config file. We need to have one to migrate stuff properly.
|
|
||||||
internal class Version3ConfigFixer
|
|
||||||
{
|
|
||||||
private readonly Logger _logger;
|
|
||||||
private readonly FilenameService _filenameService;
|
|
||||||
|
|
||||||
public Version3ConfigFixer(
|
|
||||||
Logger logger,
|
|
||||||
FilenameService filenameService)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_filenameService = filenameService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FixV3ConfigIfNeeded()
|
|
||||||
{
|
|
||||||
var oldVersionProfiles = Directory.EnumerateFiles(_filenameService.ConfigDirectory, "*.profile", SearchOption.TopDirectoryOnly);
|
|
||||||
if (oldVersionProfiles.Count() > 0 && !File.Exists(_filenameService.ConfigFile))
|
|
||||||
{
|
|
||||||
_logger.Warning("V3 config not found while profiles are available, creating dummy V3 config");
|
|
||||||
File.WriteAllText(_filenameService.ConfigFile, "{\r\n \"ViewedMessageWindows\": [],\r\n \"Version\": 3,\r\n \"PluginEnabled\": true,\r\n \"DebuggingModeEnabled\": false,\r\n \"RootPositionEditingEnabled\": false\r\n}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +1,36 @@
|
|||||||
using Dalamud.Plugin;
|
using CustomizePlus.Anamnesis;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using CustomizePlus.Api;
|
||||||
using OtterGui.Classes;
|
|
||||||
using OtterGui.Log;
|
|
||||||
using CustomizePlus.Profiles;
|
|
||||||
using CustomizePlus.Core.Services;
|
|
||||||
using CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
|
|
||||||
using CustomizePlus.Game.Services;
|
|
||||||
using CustomizePlus.Configuration.Services;
|
|
||||||
using CustomizePlus.Templates;
|
|
||||||
using CustomizePlus.UI.Windows.MainWindow.Tabs.Templates;
|
|
||||||
using CustomizePlus.Armatures.Events;
|
using CustomizePlus.Armatures.Events;
|
||||||
using CustomizePlus.Configuration.Data;
|
|
||||||
using CustomizePlus.Core.Events;
|
|
||||||
using CustomizePlus.UI;
|
|
||||||
using CustomizePlus.UI.Windows.Controls;
|
|
||||||
using CustomizePlus.Anamnesis;
|
|
||||||
using CustomizePlus.Armatures.Services;
|
using CustomizePlus.Armatures.Services;
|
||||||
using CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles;
|
using CustomizePlus.Configuration.Data;
|
||||||
using CustomizePlus.UI.Windows.MainWindow;
|
using CustomizePlus.Configuration.Services;
|
||||||
|
using CustomizePlus.Core.Events;
|
||||||
|
using CustomizePlus.Core.Services;
|
||||||
using CustomizePlus.Game.Events;
|
using CustomizePlus.Game.Events;
|
||||||
using CustomizePlus.UI.Windows;
|
using CustomizePlus.Game.Services;
|
||||||
using CustomizePlus.UI.Windows.MainWindow.Tabs;
|
|
||||||
using CustomizePlus.Templates.Events;
|
|
||||||
using CustomizePlus.Profiles.Events;
|
|
||||||
using CustomizePlus.Game.Services.GPose;
|
using CustomizePlus.Game.Services.GPose;
|
||||||
using CustomizePlus.Game.Services.GPose.ExternalTools;
|
using CustomizePlus.Game.Services.GPose.ExternalTools;
|
||||||
using CustomizePlus.GameData.Services;
|
using CustomizePlus.GameData.Services;
|
||||||
using CustomizePlus.Configuration.Services.Temporary;
|
using CustomizePlus.Profiles;
|
||||||
|
using CustomizePlus.Profiles.Events;
|
||||||
|
using CustomizePlus.Templates;
|
||||||
|
using CustomizePlus.Templates.Events;
|
||||||
|
using CustomizePlus.UI;
|
||||||
|
using CustomizePlus.UI.Windows;
|
||||||
|
using CustomizePlus.UI.Windows.Controls;
|
||||||
|
using CustomizePlus.UI.Windows.MainWindow;
|
||||||
|
using CustomizePlus.UI.Windows.MainWindow.Tabs;
|
||||||
|
using CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
|
||||||
|
using CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles;
|
||||||
|
using CustomizePlus.UI.Windows.MainWindow.Tabs.Templates;
|
||||||
|
using Dalamud.Plugin;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using OtterGui.Classes;
|
||||||
|
using OtterGui.Log;
|
||||||
|
using OtterGui.Raii;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
using Penumbra.GameData.Structs;
|
using Penumbra.GameData.Structs;
|
||||||
using OtterGui.Raii;
|
|
||||||
using CustomizePlus.Api;
|
|
||||||
|
|
||||||
namespace CustomizePlus.Core;
|
namespace CustomizePlus.Core;
|
||||||
|
|
||||||
@@ -164,8 +163,7 @@ public static class ServiceManagerBuilder
|
|||||||
{
|
{
|
||||||
services
|
services
|
||||||
.AddSingleton<PluginConfiguration>()
|
.AddSingleton<PluginConfiguration>()
|
||||||
.AddSingleton<ConfigurationMigrator>()
|
.AddSingleton<ConfigurationMigrator>();
|
||||||
.AddSingleton<Version3ConfigFixer>();
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using CustomizePlus.Api;
|
||||||
using Dalamud.Plugin;
|
using CustomizePlus.Core;
|
||||||
using OtterGui.Log;
|
|
||||||
using CustomizePlus.Core.Services;
|
using CustomizePlus.Core.Services;
|
||||||
using CustomizePlus.UI;
|
using CustomizePlus.UI;
|
||||||
using CustomizePlus.Core;
|
using Dalamud.Plugin;
|
||||||
using CustomizePlus.Configuration.Services.Temporary;
|
|
||||||
using OtterGui.Services;
|
|
||||||
using CustomizePlus.Api;
|
|
||||||
using ECommons;
|
using ECommons;
|
||||||
using ECommons.Commands;
|
using OtterGui.Log;
|
||||||
using ECommons.Configuration;
|
using OtterGui.Services;
|
||||||
using OtterGui;
|
|
||||||
using System.IO;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Linq;
|
|
||||||
using CustomizePlus.Configuration.Data;
|
|
||||||
using CustomizePlus.Core.Extensions;
|
|
||||||
using CustomizePlus.Templates;
|
|
||||||
using CustomizePlus.Profiles;
|
|
||||||
using CustomizePlus.Armatures.Services;
|
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
|
|
||||||
namespace CustomizePlus;
|
namespace CustomizePlus;
|
||||||
@@ -47,10 +33,6 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
|
|
||||||
_services.GetService<ActorManager>(); //needs to be initialized early for config to be read properly
|
_services.GetService<ActorManager>(); //needs to be initialized early for config to be read properly
|
||||||
|
|
||||||
//temporary
|
|
||||||
var v3ConfigFixer = _services.GetService<Version3ConfigFixer>();
|
|
||||||
v3ConfigFixer.FixV3ConfigIfNeeded();
|
|
||||||
|
|
||||||
_services.GetService<CustomizePlusIpc>();
|
_services.GetService<CustomizePlusIpc>();
|
||||||
_services.GetService<CPlusWindowSystem>();
|
_services.GetService<CPlusWindowSystem>();
|
||||||
_services.GetService<CommandService>();
|
_services.GetService<CommandService>();
|
||||||
|
|||||||
Reference in New Issue
Block a user