From 4c23a4bbf3f4a0d5d6cd0fcab2dac14347e7ec9b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 17 Oct 2022 15:41:00 -0700 Subject: [PATCH] Add compression result reason to log --- CHANGELIST.md | 1 + MPF.Library/DumpEnvironment.cs | 8 ++++---- MPF.Library/InfoTool.cs | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 62234b3e..0586bbfa 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -149,6 +149,7 @@ - Update Nuget packages - Remove deprecated protection setting - Update BurnOutSharp to 2.3.4 +- Add compression result reason to log ### 2.3 (2022-02-05) - Start overhauling Redump information pulling, again diff --git a/MPF.Library/DumpEnvironment.cs b/MPF.Library/DumpEnvironment.cs index a6bee542..599de669 100644 --- a/MPF.Library/DumpEnvironment.cs +++ b/MPF.Library/DumpEnvironment.cs @@ -407,11 +407,11 @@ namespace MPF.Library if (Options.CompressLogFiles) { resultProgress?.Report(Result.Success("Compressing log files...")); - success = InfoTool.CompressLogFiles(this.OutputDirectory, this.OutputFilename, this.Parameters); - if (success) - resultProgress?.Report(Result.Success("Compression complete!")); + (bool compressSuccess, string statement) = InfoTool.CompressLogFiles(this.OutputDirectory, this.OutputFilename, this.Parameters); + if (compressSuccess) + resultProgress?.Report(Result.Success(statement)); else - resultProgress?.Report(Result.Failure("Compression could not complete!")); + resultProgress?.Report(Result.Failure(statement)); } resultProgress?.Report(Result.Success("Submission information process complete!")); diff --git a/MPF.Library/InfoTool.cs b/MPF.Library/InfoTool.cs index 28f1e8ba..e53234bb 100644 --- a/MPF.Library/InfoTool.cs +++ b/MPF.Library/InfoTool.cs @@ -577,7 +577,7 @@ namespace MPF.Library /// Output filename to use as the base path /// Parameters object to use to derive log file paths /// True if the process succeeded, false otherwise - public static bool CompressLogFiles(string outputDirectory, string outputFilename, BaseParameters parameters) + public static (bool, string) CompressLogFiles(string outputDirectory, string outputFilename, BaseParameters parameters) { // Prepare the necessary paths outputFilename = Path.GetFileNameWithoutExtension(outputFilename); @@ -592,7 +592,7 @@ namespace MPF.Library files.AddRange(mpfFiles); if (!files.Any()) - return true; + return (true, "No files to compress!"); // If the file already exists, we want to delete the old one try @@ -602,7 +602,7 @@ namespace MPF.Library } catch { - return false; + return (false, "Could not delete old archive!"); } // Add the log files to the archive and delete the uncompressed file after @@ -626,11 +626,11 @@ namespace MPF.Library catch { } } - return true; + return (true, "Compression complete!"); } - catch + catch (Exception ex) { - return false; + return (false, $"Compression could not complete: {ex}"); } finally {