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
|
||||
{
|
||||
Name = $"{v3Profile.ProfileName} - {v3Profile.CharacterName}",
|
||||
//CharacterName = v3Profile.CharacterName, //todo
|
||||
//CharacterName = v3Profile.CharacterName, //no longer supported
|
||||
CreationDate = v3Profile.CreationDate,
|
||||
ModifiedDate = DateTimeOffset.UtcNow,
|
||||
Enabled = v3Profile.Enabled,
|
||||
|
||||
@@ -44,74 +44,22 @@ public class ConfigurationMigrator
|
||||
if (configVersion >= Constants.ConfigurationVersion)
|
||||
return;
|
||||
|
||||
//V3 migration code
|
||||
//We no longer support migrations of any versions < 4
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
MigrateV3ToV4();
|
||||
// /V3 migration code
|
||||
if (configVersion < 4)
|
||||
{
|
||||
_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;
|
||||
_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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user