-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quick hack fix for migrations not working due to V3 config not existing
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
CustomizePlus/Configuration/Services/Temporary/Version3ConfigFixer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters