minor refactor
This commit is contained in:
parent
c1af253300
commit
0f1ff0aa10
@ -61,7 +61,7 @@ namespace AaxDecrypter
|
|||||||
return !IsCanceled;
|
return !IsCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool Step2_DownloadAudiobookAsSingleFile()
|
private bool Step2_DownloadAudiobookAsSingleFile()
|
||||||
{
|
{
|
||||||
var zeroProgress = Step2_Start();
|
var zeroProgress = Step2_Start();
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,6 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
protected bool IsCanceled { get; set; }
|
protected bool IsCanceled { get; set; }
|
||||||
protected string OutputFileName { get; private set; }
|
protected string OutputFileName { get; private set; }
|
||||||
protected string CacheDir { get; }
|
|
||||||
protected DownloadLicense DownloadLicense { get; }
|
protected DownloadLicense DownloadLicense { get; }
|
||||||
protected NetworkFileStream InputFileStream => (nfsPersister ??= OpenNetworkFileStream()).NetworkFileStream;
|
protected NetworkFileStream InputFileStream => (nfsPersister ??= OpenNetworkFileStream()).NetworkFileStream;
|
||||||
|
|
||||||
@ -31,7 +30,8 @@ namespace AaxDecrypter
|
|||||||
protected abstract StepSequence Steps { get; }
|
protected abstract StepSequence Steps { get; }
|
||||||
private NetworkFileStreamPersister nfsPersister;
|
private NetworkFileStreamPersister nfsPersister;
|
||||||
|
|
||||||
private string jsonDownloadState => Path.Combine(CacheDir, Path.GetFileNameWithoutExtension(OutputFileName) + ".json");
|
private string cacheDir { get; }
|
||||||
|
private string jsonDownloadState => Path.Combine(cacheDir, Path.ChangeExtension(OutputFileName, ".json"));
|
||||||
private string tempFile => Path.ChangeExtension(jsonDownloadState, ".tmp");
|
private string tempFile => Path.ChangeExtension(jsonDownloadState, ".tmp");
|
||||||
|
|
||||||
public AudiobookDownloadBase(string outFileName, string cacheDirectory, DownloadLicense dlLic)
|
public AudiobookDownloadBase(string outFileName, string cacheDirectory, DownloadLicense dlLic)
|
||||||
@ -44,7 +44,7 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
if (!Directory.Exists(cacheDirectory))
|
if (!Directory.Exists(cacheDirectory))
|
||||||
throw new DirectoryNotFoundException($"Directory does not exist: {nameof(cacheDirectory)}");
|
throw new DirectoryNotFoundException($"Directory does not exist: {nameof(cacheDirectory)}");
|
||||||
CacheDir = cacheDirectory;
|
cacheDir = cacheDirectory;
|
||||||
|
|
||||||
// delete file after validation is complete
|
// delete file after validation is complete
|
||||||
FileUtility.SaferDelete(OutputFileName);
|
FileUtility.SaferDelete(OutputFileName);
|
||||||
@ -52,28 +52,24 @@ namespace AaxDecrypter
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Cancel();
|
public abstract void Cancel();
|
||||||
protected abstract bool Step2_DownloadAudiobookAsSingleFile();
|
|
||||||
protected abstract bool Step1_GetMetadata();
|
protected abstract bool Step1_GetMetadata();
|
||||||
|
|
||||||
public virtual void SetCoverArt(byte[] coverArt)
|
public virtual void SetCoverArt(byte[] coverArt)
|
||||||
{
|
{
|
||||||
if (coverArt is null) return;
|
if (coverArt is null)
|
||||||
|
return;
|
||||||
|
|
||||||
OnRetrievedCoverArt(coverArt);
|
OnRetrievedCoverArt(coverArt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool Run()
|
public bool Run()
|
||||||
{
|
{
|
||||||
var (IsSuccess, Elapsed) = Steps.Run();
|
var (IsSuccess, Elapsed) = Steps.Run();
|
||||||
|
|
||||||
if (!IsSuccess)
|
if (!IsSuccess)
|
||||||
{
|
Serilog.Log.Logger.Error("Conversion failed");
|
||||||
Console.WriteLine("WARNING-Conversion failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return IsSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnRetrievedTitle(string title)
|
protected void OnRetrievedTitle(string title)
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace AaxDecrypter
|
|||||||
return !IsCanceled;
|
return !IsCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool Step2_DownloadAudiobookAsSingleFile()
|
private bool Step2_DownloadAudiobookAsSingleFile()
|
||||||
{
|
{
|
||||||
DateTime startTime = DateTime.Now;
|
DateTime startTime = DateTime.Now;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user