From 1fc6476f7160acbb35d7fc58684a8411fff1b96d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 27 May 2021 11:46:47 -0700 Subject: [PATCH] Be smarter about checking for zipped logs --- CHANGELIST.md | 1 + MPF.Library/Aaru/Parameters.cs | 6 +++--- MPF.Library/CleanRIp/Parameters.cs | 4 ++-- MPF.Library/DD/Parameters.cs | 2 +- MPF.Library/Data/BaseParameters.cs | 3 ++- MPF.Library/Data/DumpEnvironment.cs | 10 +++++----- MPF.Library/DiscImageCreator/Parameters.cs | 8 ++++---- MPF.Library/UmdImageCreator/Parameters.cs | 4 ++-- MPF/Windows/MainWindow.xaml.cs | 2 +- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 364cfff9..390415f9 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -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) diff --git a/MPF.Library/Aaru/Parameters.cs b/MPF.Library/Aaru/Parameters.cs index 9d26a02f..7d271759 100644 --- a/MPF.Library/Aaru/Parameters.cs +++ b/MPF.Library/Aaru/Parameters.cs @@ -135,13 +135,13 @@ namespace MPF.Aaru #region BaseParameters Implementations /// - public override (bool, List) CheckAllOutputFilesExist(string basePath) + public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { List missingFiles = new List(); 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"); diff --git a/MPF.Library/CleanRIp/Parameters.cs b/MPF.Library/CleanRIp/Parameters.cs index 0f57e812..5f93aec4 100644 --- a/MPF.Library/CleanRIp/Parameters.cs +++ b/MPF.Library/CleanRIp/Parameters.cs @@ -30,7 +30,7 @@ namespace MPF.CleanRip #region BaseParameters Implementations /// - public override (bool, List) CheckAllOutputFilesExist(string basePath) + public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { List missingFiles = new List(); 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"); diff --git a/MPF.Library/DD/Parameters.cs b/MPF.Library/DD/Parameters.cs index fab708fd..fd8d31e7 100644 --- a/MPF.Library/DD/Parameters.cs +++ b/MPF.Library/DD/Parameters.cs @@ -67,7 +67,7 @@ namespace MPF.DD #region BaseParameters Implementations /// - public override (bool, List) CheckAllOutputFilesExist(string basePath) + public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { // TODO: Figure out what sort of output files are expected... just `.bin`? return (true, new List()); diff --git a/MPF.Library/Data/BaseParameters.cs b/MPF.Library/Data/BaseParameters.cs index d6900b50..5c9b586f 100644 --- a/MPF.Library/Data/BaseParameters.cs +++ b/MPF.Library/Data/BaseParameters.cs @@ -152,8 +152,9 @@ namespace MPF.Data /// Validate if all required output files exist /// /// Base filename and path to use for checking + /// True if this is a check done before a dump, false if done after /// Tuple of true if all required files exist, false otherwise and a list representing missing files - public abstract (bool, List) CheckAllOutputFilesExist(string basePath); + public abstract (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck); /// /// Generate a SubmissionInfo for the output files diff --git a/MPF.Library/Data/DumpEnvironment.cs b/MPF.Library/Data/DumpEnvironment.cs index d83e4290..e0ddb804 100644 --- a/MPF.Library/Data/DumpEnvironment.cs +++ b/MPF.Library/Data/DumpEnvironment.cs @@ -176,9 +176,9 @@ namespace MPF.Data /// /// Ensures that all required output files have been created /// - /// Optional result progress callback + /// True if this is a check done before a dump, false if done after /// Tuple of true if all required files exist, false otherwise and a list representing missing files - public (bool, List) FoundAllFiles() + public (bool, List) 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); } /// @@ -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 missingFiles) = FoundAllFiles(); + (bool foundFiles, List 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 missingFiles) = FoundAllFiles(); + (bool foundFiles, List missingFiles) = FoundAllFiles(false); if (!foundFiles) { resultProgress.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", missingFiles)}")); diff --git a/MPF.Library/DiscImageCreator/Parameters.cs b/MPF.Library/DiscImageCreator/Parameters.cs index 018f4313..fda4d83a 100644 --- a/MPF.Library/DiscImageCreator/Parameters.cs +++ b/MPF.Library/DiscImageCreator/Parameters.cs @@ -162,7 +162,7 @@ namespace MPF.DiscImageCreator #region BaseParameters Implementations /// - public override (bool, List) CheckAllOutputFilesExist(string basePath) + public override (bool, List) 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"); diff --git a/MPF.Library/UmdImageCreator/Parameters.cs b/MPF.Library/UmdImageCreator/Parameters.cs index 45daa33b..0a5c306b 100644 --- a/MPF.Library/UmdImageCreator/Parameters.cs +++ b/MPF.Library/UmdImageCreator/Parameters.cs @@ -30,13 +30,13 @@ namespace MPF.UmdImageCreator #region BaseParameters Implementations /// - public override (bool, List) CheckAllOutputFilesExist(string basePath) + public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { List missingFiles = new List(); 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"); diff --git a/MPF/Windows/MainWindow.xaml.cs b/MPF/Windows/MainWindow.xaml.cs index 2c855aef..76d2ce02 100644 --- a/MPF/Windows/MainWindow.xaml.cs +++ b/MPF/Windows/MainWindow.xaml.cs @@ -889,7 +889,7 @@ namespace MPF.Windows } // If a complete dump already exists - (bool foundFiles, List _) = Env.FoundAllFiles(); + (bool foundFiles, List _) = 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);