new user: init settings
This commit is contained in:
parent
5059333b38
commit
c6e9ba9bf9
@ -50,19 +50,50 @@ namespace AppScaffolding
|
|||||||
public static void RunPostConfigMigrations(Configuration config)
|
public static void RunPostConfigMigrations(Configuration config)
|
||||||
{
|
{
|
||||||
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
||||||
|
PopulateMissingConfigValues(config);
|
||||||
|
|
||||||
//
|
//
|
||||||
// migrations go below here
|
// migrations go below here
|
||||||
//
|
//
|
||||||
|
|
||||||
Migrations.migrate_to_v5_2_0__post_config(config);
|
|
||||||
Migrations.migrate_to_v5_7_1(config);
|
|
||||||
Migrations.migrate_to_v6_1_2(config);
|
|
||||||
Migrations.migrate_to_v6_2_0(config);
|
|
||||||
Migrations.migrate_to_v6_2_9(config);
|
|
||||||
Migrations.migrate_to_v6_5_2(config);
|
Migrations.migrate_to_v6_5_2(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PopulateMissingConfigValues(Configuration config)
|
||||||
|
{
|
||||||
|
config.InProgress ??= Configuration.WinTemp;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.AllowLibationFixup)))
|
||||||
|
config.AllowLibationFixup = true;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.DecryptToLossy)))
|
||||||
|
config.DecryptToLossy = false;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.BadBook)))
|
||||||
|
config.BadBook = Configuration.BadBookAction.Ask;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.DownloadEpisodes)))
|
||||||
|
config.DownloadEpisodes = true;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.ImportEpisodes)))
|
||||||
|
config.ImportEpisodes = true;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.SplitFilesByChapter)))
|
||||||
|
config.SplitFilesByChapter = false;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.FolderTemplate)))
|
||||||
|
config.FolderTemplate = Templates.Folder.DefaultTemplate;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.FileTemplate)))
|
||||||
|
config.FileTemplate = Templates.File.DefaultTemplate;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.ChapterFileTemplate)))
|
||||||
|
config.ChapterFileTemplate = Templates.ChapterFile.DefaultTemplate;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.ShowImportedStats)))
|
||||||
|
config.ShowImportedStats = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initialize logging. Run after migration</summary>
|
/// <summary>Initialize logging. Run after migration</summary>
|
||||||
public static void RunPostMigrationScaffolding(Configuration config)
|
public static void RunPostMigrationScaffolding(Configuration config)
|
||||||
{
|
{
|
||||||
@ -313,59 +344,11 @@ namespace AppScaffolding
|
|||||||
"WinTemp" => Path.GetFullPath(Path.Combine(Path.GetTempPath(), "Libation")),
|
"WinTemp" => Path.GetFullPath(Path.Combine(Path.GetTempPath(), "Libation")),
|
||||||
_ => path
|
_ => path
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void migrate_to_v5_2_0__post_config(Configuration config)
|
|
||||||
{
|
|
||||||
if (!config.Exists(nameof(config.AllowLibationFixup)))
|
|
||||||
config.AllowLibationFixup = true;
|
|
||||||
|
|
||||||
if (!config.Exists(nameof(config.DecryptToLossy)))
|
|
||||||
config.DecryptToLossy = false;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// add config.BadBook
|
|
||||||
public static void migrate_to_v5_7_1(Configuration config)
|
|
||||||
{
|
|
||||||
if (!config.Exists(nameof(config.BadBook)))
|
|
||||||
config.BadBook = Configuration.BadBookAction.Ask;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add config.DownloadEpisodes , config.ImportEpisodes
|
|
||||||
public static void migrate_to_v6_1_2(Configuration config)
|
|
||||||
{
|
|
||||||
if (!config.Exists(nameof(config.DownloadEpisodes)))
|
|
||||||
config.DownloadEpisodes = true;
|
|
||||||
|
|
||||||
if (!config.Exists(nameof(config.ImportEpisodes)))
|
|
||||||
config.ImportEpisodes = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add config.SplitFilesByChapter
|
|
||||||
public static void migrate_to_v6_2_0(Configuration config)
|
|
||||||
{
|
|
||||||
if (!config.Exists(nameof(config.SplitFilesByChapter)))
|
|
||||||
config.SplitFilesByChapter = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add file naming templates
|
|
||||||
public static void migrate_to_v6_2_9(Configuration config)
|
|
||||||
{
|
|
||||||
if (!config.Exists(nameof(config.FolderTemplate)))
|
|
||||||
config.FolderTemplate = Templates.Folder.DefaultTemplate;
|
|
||||||
|
|
||||||
if (!config.Exists(nameof(config.FileTemplate)))
|
|
||||||
config.FileTemplate = Templates.File.DefaultTemplate;
|
|
||||||
|
|
||||||
if (!config.Exists(nameof(config.ChapterFileTemplate)))
|
|
||||||
config.ChapterFileTemplate = Templates.ChapterFile.DefaultTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add config.ShowImportedStats
|
|
||||||
public static void migrate_to_v6_5_2(Configuration config)
|
public static void migrate_to_v6_5_2(Configuration config)
|
||||||
{
|
{
|
||||||
if (!config.Exists(nameof(config.ShowImportedStats)))
|
// example
|
||||||
config.ShowImportedStats = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,9 +138,10 @@ namespace LibationWinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INIT DEFAULT SETTINGS
|
||||||
// if 'new user' was clicked, or if 'returning user' chose new install: show basic settings dialog
|
// if 'new user' was clicked, or if 'returning user' chose new install: show basic settings dialog
|
||||||
config.Books ??= Path.Combine(defaultLibationFilesDir, "Books");
|
config.Books ??= Path.Combine(defaultLibationFilesDir, "Books");
|
||||||
config.InProgress ??= Configuration.WinTemp;
|
AppScaffolding.LibationScaffolding.PopulateMissingConfigValues(config);
|
||||||
|
|
||||||
if (new SettingsDialog().ShowDialog() != DialogResult.OK)
|
if (new SettingsDialog().ShowDialog() != DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user