From b768362eae3b1ddab0ac99a3a12c290c054ad721 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Tue, 18 Aug 2020 06:51:12 -0400 Subject: [PATCH] migrate old files/settings --- .../UNTESTED/AudibleApiActions.cs | 2 +- LibationLauncher/LibationLauncher.csproj | 2 +- LibationLauncher/UNTESTED/Program.cs | 24 +++++++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/InternalUtilities/UNTESTED/AudibleApiActions.cs b/InternalUtilities/UNTESTED/AudibleApiActions.cs index 8ed07999..971f55bb 100644 --- a/InternalUtilities/UNTESTED/AudibleApiActions.cs +++ b/InternalUtilities/UNTESTED/AudibleApiActions.cs @@ -24,7 +24,7 @@ namespace InternalUtilities { Localization.SetLocale(Configuration.Instance.LocaleCountryCode); - return await EzApiCreator.GetApiAsync(AudibleApiStorage.AccountsSettingsFile, AudibleApiStorage.GetJsonPath(), loginCallback); + return await EzApiCreator.GetApiAsync(AudibleApiStorage.AccountsSettingsFile, AudibleApiStorage.GetIdentityTokensJsonPath(), loginCallback); } private static AsyncRetryPolicy policy { get; } diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index ae4842c1..2d25b158 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.12.120 + 3.1.12.123 diff --git a/LibationLauncher/UNTESTED/Program.cs b/LibationLauncher/UNTESTED/Program.cs index 346340c8..794d2ef6 100644 --- a/LibationLauncher/UNTESTED/Program.cs +++ b/LibationLauncher/UNTESTED/Program.cs @@ -26,7 +26,6 @@ namespace LibationLauncher AudibleApiStorage.EnsureAccountsSettingsFileExists(); migrateIdentityFile(); - updateSettingsFile(); ensureLoggingConfig(); ensureSerilogConfig(); @@ -101,6 +100,9 @@ namespace LibationLauncher // delete legacy token file File.Delete(AudibleApiStorage.AccountsSettingsFileLegacy30); + + // in reality, only need to run this when migating v3 => v4. put inside here so already upgraded versions won't make this check + updateSettingsFile(); } private static void updateLegacyFileWithLocale() @@ -170,15 +172,27 @@ namespace LibationLauncher if (!File.Exists(Configuration.Instance.SettingsFilePath)) return; +// don't delete old settings until new values are used +// remember to remove these from Configuration.cs +throw new NotImplementedException(); + // use JObject to remove decrypt key and locale from Settings.json var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath); var jObj = JObject.Parse(settingsContents); - jObj.Property("DecryptKey")?.Remove(); - jObj.Property("LocaleCountryCode")?.Remove(); + var resave = false; -// remember to remove these from Configuration.cs -throw new NotImplementedException(); + var jDecryptKey = jObj.Property("DecryptKey"); + var jLocale = jObj.Property("LocaleCountryCode"); + + jDecryptKey?.Remove(); + jLocale?.Remove(); + + if (jDecryptKey != null || jLocale != null) + { + var newContents = jObj.ToString(Formatting.Indented); + File.WriteAllText(Configuration.Instance.SettingsFilePath, newContents); + } } private static string defaultLoggingLevel { get; } = "Information";