Refactor valid path/filename. Centralize validaion. Universal templating is one step closer

This commit is contained in:
Robert McRackan 2021-10-18 13:36:55 -04:00
parent 7720110460
commit d08962cffa
18 changed files with 415 additions and 74 deletions

View file

@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="AAXClean" Version="0.1.9" />
<PackageReference Include="Dinah.Core" Version="2.0.0.1" />
<PackageReference Include="Dinah.Core" Version="2.0.1.1" />
</ItemGroup>
<ItemGroup>

View file

@ -32,7 +32,7 @@ namespace AaxDecrypter
private NetworkFileStreamPersister nfsPersister;
private string jsonDownloadState => Path.Combine(CacheDir, Path.GetFileNameWithoutExtension(OutputFileName) + ".json");
private string tempFile => PathLib.ReplaceExtension(jsonDownloadState, ".tmp");
private string tempFile => Path.ChangeExtension(jsonDownloadState, ".tmp");
public AudiobookDownloadBase(string outFileName, string cacheDirectory, DownloadLicense dlLic)
{
@ -102,7 +102,7 @@ namespace AaxDecrypter
// not a critical step. its failure should not prevent future steps from running
try
{
var path = PathLib.ReplaceExtension(OutputFileName, ".cue");
var path = Path.ChangeExtension(OutputFileName, ".cue");
path = FileUtility.GetValidFilename(path);
File.WriteAllText(path, Cue.CreateContents(Path.GetFileName(OutputFileName), DownloadLicense.ChapterInfo));
OnFileCreated(path);

View file

@ -19,8 +19,8 @@ namespace AaxDecrypter
["Step 1: Get Mp3 Metadata"] = Step1_GetMetadata,
["Step 2: Download Audiobook"] = Step2_DownloadAudiobookAsSingleFile,
["Step 3: Create Cue"] = Step3_CreateCue,
["Step 4: Cleanup"] = Step4_Cleanup,
["Step 3: Create Cue"] = Step_CreateCue,
["Step 4: Cleanup"] = Step_Cleanup,
};
}
@ -66,9 +66,9 @@ namespace AaxDecrypter
CloseInputFileStream();
var realOutputFileName = FileUtility.Move(InputFileStream.SaveFilePath, OutputFileName);
var realOutputFileName = FileUtility.SaferMoveToValidPath(InputFileStream.SaveFilePath, OutputFileName);
SetOutputFileName(realOutputFileName);
OnFileCreated(OutputFileName);
OnFileCreated(realOutputFileName);
return !IsCanceled;
}