diff --git a/FileLiberator/UNTESTED/DownloadBook.cs b/FileLiberator/UNTESTED/DownloadBook.cs index f7ad8c8c..f3eecbfb 100644 --- a/FileLiberator/UNTESTED/DownloadBook.cs +++ b/FileLiberator/UNTESTED/DownloadBook.cs @@ -67,7 +67,7 @@ namespace FileLiberator : "Error downloading file"; var ex = new Exception(exMsg); - Serilog.Log.Error(ex, "Download error {@DebugInfo}", new + Serilog.Log.Logger.Error(ex, "Download error {@DebugInfo}", new { libraryBook.Book.Title, libraryBook.Book.AudibleProductId, diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index c9a2c28e..39e35052 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.12.316 + 3.1.12.331 diff --git a/LibationLauncher/UNTESTED/Program.cs b/LibationLauncher/UNTESTED/Program.cs index 31442faa..4e5be0a6 100644 --- a/LibationLauncher/UNTESTED/Program.cs +++ b/LibationLauncher/UNTESTED/Program.cs @@ -99,9 +99,12 @@ namespace LibationLauncher { updateLegacyFileWithLocale(); - var account = addAccountToNewAccountFile(); + var account = createAccountFromLegacySettings(); + account.DecryptKey = getDecryptKey(account); - importDecryptKey(account); + // the next few methods need persistence. to be a good citizen, dispose of persister at the end of current scope + using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); + persister.AccountsSettings.Add(account); } // migration is a convenience. if something goes wrong: just move on catch { } @@ -133,7 +136,7 @@ namespace LibationLauncher } } - private static Account addAccountToNewAccountFile() + private static Account createAccountFromLegacySettings() { // get required locale from settings file var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath); @@ -161,24 +164,22 @@ namespace LibationLauncher IdentityTokens = identity }; - // saves to new file - using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); - persister.AccountsSettings.Add(account); - return account; } - private static void importDecryptKey(Account account) + private static string getDecryptKey(Account account) { - if (account is null || !string.IsNullOrWhiteSpace(account.DecryptKey) || !File.Exists(Configuration.Instance.SettingsFilePath)) - return; + if (!string.IsNullOrWhiteSpace(account?.DecryptKey)) + return account.DecryptKey; + + if (!File.Exists(Configuration.Instance.SettingsFilePath) || account is null) + return ""; var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath); if (JObject.Parse(settingsContents).TryGetValue("DecryptKey", out var jToken)) - { - var decryptKey = jToken.Value() ?? ""; - account.DecryptKey = decryptKey; - } + return jToken.Value() ?? ""; + + return ""; } private static void updateSettingsFile() diff --git a/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.Designer.cs b/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.Designer.cs index 0fa198db..4b4126ba 100644 --- a/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.Designer.cs +++ b/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.Designer.cs @@ -36,7 +36,7 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(28, 24); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(260, 13); + this.label1.Size = new System.Drawing.Size(263, 13); this.label1.TabIndex = 0; this.label1.Text = "Scanning Audible library. This may take a few minutes"; // @@ -44,7 +44,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(319, 63); + this.ClientSize = new System.Drawing.Size(440, 63); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; diff --git a/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs b/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs index ca843515..f3b6594c 100644 --- a/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs +++ b/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs @@ -33,9 +33,10 @@ namespace LibationWinForms.Dialogs { (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync((account) => new WinformResponder(account), _accounts); } - catch + catch (Exception ex) { var msg = "Error importing library. Please try again. If this still happens after 2 or 3 tries, stop and contact administrator"; + Serilog.Log.Logger.Error(ex, msg); MessageBox.Show(msg, "Error importing library", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/WinFormsDesigner/Dialogs/IndexLibraryDialog.Designer.cs b/WinFormsDesigner/Dialogs/IndexLibraryDialog.Designer.cs index 7947a45a..d22ce14a 100644 --- a/WinFormsDesigner/Dialogs/IndexLibraryDialog.Designer.cs +++ b/WinFormsDesigner/Dialogs/IndexLibraryDialog.Designer.cs @@ -36,15 +36,15 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(28, 24); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(260, 13); + this.label1.Size = new System.Drawing.Size(263, 13); this.label1.TabIndex = 0; - this.label1.Text = "Scanning Audible library. This may take a few minutes"; + this.label1.Text = "Scanning Audible library. This may take a few minutes."; // // IndexLibraryDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(319, 63); + this.ClientSize = new System.Drawing.Size(440, 63); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false;