Config setting to retain aax file after decrypt
This commit is contained in:
parent
389761355d
commit
9e1d657f60
@ -62,9 +62,21 @@ namespace FileLiberator
|
|||||||
if (outputAudioFilename == null)
|
if (outputAudioFilename == null)
|
||||||
return new StatusHandler { "Decrypt failed" };
|
return new StatusHandler { "Decrypt failed" };
|
||||||
|
|
||||||
moveFilesToBooksDir(libraryBook.Book, outputAudioFilename);
|
var destinationDir = moveFilesToBooksDir(libraryBook.Book, outputAudioFilename);
|
||||||
|
|
||||||
|
var config = Configuration.Instance;
|
||||||
|
if (config.RetainAaxFiles)
|
||||||
|
{
|
||||||
|
var newAaxFilename = FileUtility.GetValidFilename(
|
||||||
|
destinationDir,
|
||||||
|
Path.GetFileNameWithoutExtension(aaxFilename),
|
||||||
|
"aax");
|
||||||
|
File.Move(aaxFilename, newAaxFilename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Dinah.Core.IO.FileExt.SafeDelete(aaxFilename);
|
Dinah.Core.IO.FileExt.SafeDelete(aaxFilename);
|
||||||
|
}
|
||||||
|
|
||||||
var statusHandler = new StatusHandler();
|
var statusHandler = new StatusHandler();
|
||||||
var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
|
var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
|
||||||
@ -120,7 +132,7 @@ namespace FileLiberator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void moveFilesToBooksDir(Book product, string outputAudioFilename)
|
private static string moveFilesToBooksDir(Book product, string outputAudioFilename)
|
||||||
{
|
{
|
||||||
// create final directory. move each file into it. MOVE AUDIO FILE LAST
|
// create final directory. move each file into it. MOVE AUDIO FILE LAST
|
||||||
// new dir: safetitle_limit50char + " [" + productId + "]"
|
// new dir: safetitle_limit50char + " [" + productId + "]"
|
||||||
@ -142,6 +154,8 @@ namespace FileLiberator
|
|||||||
|
|
||||||
File.Move(f.FullName, dest);
|
File.Move(f.FullName, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return destinationDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string getDestDir(Book product)
|
private static string getDestDir(Book product)
|
||||||
|
|||||||
@ -83,6 +83,13 @@ namespace FileManager
|
|||||||
set => persistentDictionary.Set(nameof(DecryptInProgressEnum), value);
|
set => persistentDictionary.Set(nameof(DecryptInProgressEnum), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Description("Retain .aax files after decrypting?")]
|
||||||
|
public bool RetainAaxFiles
|
||||||
|
{
|
||||||
|
get => persistentDictionary.Get<bool>(nameof(RetainAaxFiles));
|
||||||
|
set => persistentDictionary.Set(nameof(RetainAaxFiles), value);
|
||||||
|
}
|
||||||
|
|
||||||
// note: any potential file manager static ctors can't compensate if storage dir is changed at run time via settings. this is partly bad architecture. but the side effect is desirable. if changing LibationFiles location: restart app
|
// note: any potential file manager static ctors can't compensate if storage dir is changed at run time via settings. this is partly bad architecture. but the side effect is desirable. if changing LibationFiles location: restart app
|
||||||
|
|
||||||
// singleton stuff
|
// singleton stuff
|
||||||
|
|||||||
@ -40,8 +40,13 @@ namespace FileManager
|
|||||||
return stringCache[propertyName];
|
return stringCache[propertyName];
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Get<T>(string propertyName) where T : class
|
public T Get<T>(string propertyName)
|
||||||
=> GetObject(propertyName) is T obj ? obj : default;
|
{
|
||||||
|
var o = GetObject(propertyName);
|
||||||
|
if (o is null) return default;
|
||||||
|
if (o is JToken jt) return jt.Value<T>();
|
||||||
|
return (T)o;
|
||||||
|
}
|
||||||
|
|
||||||
public object GetObject(string propertyName)
|
public object GetObject(string propertyName)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>4.0.2.3</Version>
|
<Version>4.0.2.21</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -27,7 +27,8 @@ namespace LibationLauncher
|
|||||||
|
|
||||||
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
||||||
|
|
||||||
migrate_v3_to_v4();
|
migrate_to_v4_0_0();
|
||||||
|
migrate_to_v4_0_3(); // add setting for whether to delete/retain aax
|
||||||
|
|
||||||
ensureLoggingConfig();
|
ensureLoggingConfig();
|
||||||
ensureSerilogConfig();
|
ensureSerilogConfig();
|
||||||
@ -83,7 +84,7 @@ namespace LibationLauncher
|
|||||||
#region v3 => v4 migration
|
#region v3 => v4 migration
|
||||||
static string AccountsSettingsFileLegacy30 => Path.Combine(Configuration.Instance.LibationFiles, "IdentityTokens.json");
|
static string AccountsSettingsFileLegacy30 => Path.Combine(Configuration.Instance.LibationFiles, "IdentityTokens.json");
|
||||||
|
|
||||||
private static void migrate_v3_to_v4()
|
private static void migrate_to_v4_0_0()
|
||||||
{
|
{
|
||||||
migrateLegacyIdentityFile();
|
migrateLegacyIdentityFile();
|
||||||
|
|
||||||
@ -205,6 +206,27 @@ namespace LibationLauncher
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region migrate_to_v4_0_3 add setting for whether to delete/retain aax
|
||||||
|
private static void migrate_to_v4_0_3()
|
||||||
|
{
|
||||||
|
if (!File.Exists(Configuration.Instance.SettingsFilePath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// use JObject to remove decrypt key and locale from Settings.json
|
||||||
|
var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath);
|
||||||
|
var jObj = JObject.Parse(settingsContents);
|
||||||
|
|
||||||
|
var jRetainAaxFiles = jObj.Property("RetainAaxFiles");
|
||||||
|
if (jRetainAaxFiles is null)
|
||||||
|
{
|
||||||
|
jObj.Add("RetainAaxFiles", false);
|
||||||
|
|
||||||
|
var newContents = jObj.ToString(Formatting.Indented);
|
||||||
|
File.WriteAllText(Configuration.Instance.SettingsFilePath, newContents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private static string defaultLoggingLevel { get; } = "Information";
|
private static string defaultLoggingLevel { get; } = "Information";
|
||||||
private static void ensureLoggingConfig()
|
private static void ensureLoggingConfig()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user