Be smarter about checking for zipped logs

This commit is contained in:
Matt Nadareski
2021-05-27 11:46:47 -07:00
parent 53e5a1b1b1
commit 1fc6476f71
9 changed files with 21 additions and 19 deletions

View File

@@ -6,6 +6,7 @@
- Fix negative offsets for `/a` flag
- Always check for all DIC log files, just in case
- Check for the zipped logs for dealing with overwrites
- Be smarter about checking for zipped logs
### 2.0 (2021-04-23)
- Rename DICUI to Media Preservation Frontend (MPF)

View File

@@ -135,13 +135,13 @@ namespace MPF.Aaru
#region BaseParameters Implementations
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath)
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
switch (this.Type)
{
case MediaType.CDROM:
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}.cicm.xml"))
missingFiles.Add($"{basePath}.cicm.xml");
@@ -162,7 +162,7 @@ namespace MPF.Aaru
case MediaType.DVD:
case MediaType.HDDVD:
case MediaType.BluRay:
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}.cicm.xml"))
missingFiles.Add($"{basePath}.cicm.xml");

View File

@@ -30,7 +30,7 @@ namespace MPF.CleanRip
#region BaseParameters Implementations
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath)
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
switch (this.Type)
@@ -38,7 +38,7 @@ namespace MPF.CleanRip
case MediaType.DVD: // Only added here to help users; not strictly correct
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}-dumpinfo.txt"))
missingFiles.Add($"{basePath}-dumpinfo.txt");

View File

@@ -67,7 +67,7 @@ namespace MPF.DD
#region BaseParameters Implementations
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath)
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
// TODO: Figure out what sort of output files are expected... just `.bin`?
return (true, new List<string>());

View File

@@ -152,8 +152,9 @@ namespace MPF.Data
/// Validate if all required output files exist
/// </summary>
/// <param name="basePath">Base filename and path to use for checking</param>
/// <param name="preCheck">True if this is a check done before a dump, false if done after</param>
/// <returns>Tuple of true if all required files exist, false otherwise and a list representing missing files</returns>
public abstract (bool, List<string>) CheckAllOutputFilesExist(string basePath);
public abstract (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck);
/// <summary>
/// Generate a SubmissionInfo for the output files

View File

@@ -176,9 +176,9 @@ namespace MPF.Data
/// <summary>
/// Ensures that all required output files have been created
/// </summary>
/// <param name="progress">Optional result progress callback</param>
/// <param name="preCheck">True if this is a check done before a dump, false if done after</param>
/// <returns>Tuple of true if all required files exist, false otherwise and a list representing missing files</returns>
public (bool, List<string>) FoundAllFiles()
public (bool, List<string>) FoundAllFiles(bool preCheck)
{
// First, sanitized the output filename to strip off any potential extension
string outputFilename = Path.GetFileNameWithoutExtension(OutputFilename);
@@ -187,7 +187,7 @@ namespace MPF.Data
string basePath = Path.Combine(OutputDirectory, outputFilename);
// Finally, let the parameters say if all files exist
return Parameters.CheckAllOutputFilesExist(basePath);
return Parameters.CheckAllOutputFilesExist(basePath, preCheck);
}
/// <summary>
@@ -412,7 +412,7 @@ namespace MPF.Data
resultProgress?.Report(Result.Success("Gathering submission information... please wait!"));
// Check to make sure that the output had all the correct files
(bool foundFiles, List<string> missingFiles) = FoundAllFiles();
(bool foundFiles, List<string> missingFiles) = FoundAllFiles(false);
if (!foundFiles)
{
resultProgress.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", missingFiles)}"));
@@ -568,7 +568,7 @@ namespace MPF.Data
string outputFilename = Path.GetFileNameWithoutExtension(OutputFilename);
// Check that all of the relevant files are there
(bool foundFiles, List<string> missingFiles) = FoundAllFiles();
(bool foundFiles, List<string> missingFiles) = FoundAllFiles(false);
if (!foundFiles)
{
resultProgress.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", missingFiles)}"));

View File

@@ -162,7 +162,7 @@ namespace MPF.DiscImageCreator
#region BaseParameters Implementations
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath)
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
/*
If there are no external programs, such as error checking, etc., DIC outputs
@@ -227,7 +227,7 @@ namespace MPF.DiscImageCreator
missingFiles.Add($"{basePath}.scm");
}
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}.ccd"))
missingFiles.Add($"{basePath}.ccd");
@@ -289,7 +289,7 @@ namespace MPF.DiscImageCreator
case MediaType.BluRay:
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}.dat"))
missingFiles.Add($"{basePath}.dat");
@@ -318,7 +318,7 @@ namespace MPF.DiscImageCreator
case MediaType.FloppyDisk:
case MediaType.HardDisk:
// TODO: Determine what outputs come out from a HDD, SD, etc.
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}.dat"))
missingFiles.Add($"{basePath}.dat");

View File

@@ -30,13 +30,13 @@ namespace MPF.UmdImageCreator
#region BaseParameters Implementations
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath)
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
switch (this.Type)
{
case MediaType.UMD:
if (!File.Exists($"{basePath}_logs.zip"))
if (!File.Exists($"{basePath}_logs.zip") || !preCheck)
{
if (!File.Exists($"{basePath}_disc.txt"))
missingFiles.Add($"{basePath}_disc.txt");

View File

@@ -889,7 +889,7 @@ namespace MPF.Windows
}
// If a complete dump already exists
(bool foundFiles, List<string> _) = Env.FoundAllFiles();
(bool foundFiles, List<string> _) = Env.FoundAllFiles(true);
if (foundFiles)
{
MessageBoxResult mbresult = CustomMessageBox.Show("A complete dump already exists! Are you sure you want to overwrite?", "Overwrite?", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);