From 91a0e85e24dff16e76c8afafd8397d537e9626b6 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 28 May 2024 10:34:33 -0400 Subject: [PATCH] Centralize dumping program information gathering --- CHANGELIST.md | 1 + MPF.Frontend/SubmissionGenerator.cs | 29 +++++++++++++++++++++++++++-- MPF.Processors/Aaru.cs | 4 +--- MPF.Processors/BaseProcessor.cs | 1 - MPF.Processors/CleanRip.cs | 4 +--- MPF.Processors/DiscImageCreator.cs | 3 ++- MPF.Processors/PS3CFW.cs | 3 ++- MPF.Processors/Redumper.cs | 3 ++- MPF.Processors/UmdImageCreator.cs | 4 +--- MPF.Processors/XboxBackupCreator.cs | 3 ++- 10 files changed, 39 insertions(+), 16 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 2cd031c1..7b9c9daa 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -130,6 +130,7 @@ - Move ListPrograms to OptionsLoader - Move DoesSupportDriveSpeed to DumpEnvironment - Move ToInternalProgram to Options +- Centralize dumping program information gathering ### 3.1.9a (2024-05-21) diff --git a/MPF.Frontend/SubmissionGenerator.cs b/MPF.Frontend/SubmissionGenerator.cs index 9b3b3c43..431f1b4d 100644 --- a/MPF.Frontend/SubmissionGenerator.cs +++ b/MPF.Frontend/SubmissionGenerator.cs @@ -78,7 +78,7 @@ namespace MPF.Frontend combinedBase = Path.Combine(outputDirectory, outputFilename); // Create the default submission info - SubmissionInfo info = CreateDefaultSubmissionInfo(system, mediaType, options.AddPlaceholders); + SubmissionInfo info = CreateDefaultSubmissionInfo(processor, system, mediaType, options.AddPlaceholders); // Get specific tool output handling processor?.GenerateSubmissionInfo(info, combinedBase, drive, options.EnableRedumpCompatibility); @@ -343,7 +343,7 @@ namespace MPF.Frontend /// /// Creates a default SubmissionInfo object based on the current system and media type /// - private static SubmissionInfo CreateDefaultSubmissionInfo(RedumpSystem? system, MediaType? mediaType, bool addPlaceholders) + private static SubmissionInfo CreateDefaultSubmissionInfo(BaseProcessor processor, RedumpSystem? system, MediaType? mediaType, bool addPlaceholders) { // Create the template object var info = new SubmissionInfo() @@ -370,6 +370,7 @@ namespace MPF.Frontend DumpingInfo = new DumpingInfoSection() { FrontendVersion = Tools.GetCurrentVersion(), + DumpingProgram = GetDumpingProgramFromProcessor(processor), }, }; @@ -378,6 +379,30 @@ namespace MPF.Frontend return info; } + /// + /// Get the dumping program name from the processor + /// + /// + /// + private static string? GetDumpingProgramFromProcessor(BaseProcessor processor) + { + // Map to the internal program + InternalProgram? internalProgram = processor switch + { + Processors.Aaru => InternalProgram.Aaru, + CleanRip => InternalProgram.CleanRip, + DiscImageCreator => InternalProgram.DiscImageCreator, + PS3CFW => InternalProgram.PS3CFW, + Redumper => InternalProgram.Redumper, + UmdImageCreator => InternalProgram.UmdImageCreator, + XboxBackupCreator => InternalProgram.XboxBackupCreator, + _ => null, + }; + + // Use the internal program to map to the name + return internalProgram.LongName(); + } + /// /// Formats a list of volume labels and their corresponding filesystems /// diff --git a/MPF.Processors/Aaru.cs b/MPF.Processors/Aaru.cs index 16f9e928..dfd28123 100644 --- a/MPF.Processors/Aaru.cs +++ b/MPF.Processors/Aaru.cs @@ -7,7 +7,6 @@ using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using MPF.Core; -using MPF.Core.Utilities; using SabreTools.Models.CueSheets; using SabreTools.Models.Logiqx; using SabreTools.RedumpLib; @@ -110,8 +109,7 @@ namespace MPF.Processors info = Builder.EnsureAllSections(info); // TODO: Determine if there's an Aaru version anywhere - info.DumpingInfo!.DumpingProgram = EnumExtensions.LongName(InternalProgram.Aaru); - info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + ".cicm.xml")?.ToString("yyyy-MM-dd HH:mm:ss"); + info.DumpingInfo!.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + ".cicm.xml")?.ToString("yyyy-MM-dd HH:mm:ss"); // Deserialize the sidecar, if possible var sidecar = GenerateSidecar(basePath + ".cicm.xml"); diff --git a/MPF.Processors/BaseProcessor.cs b/MPF.Processors/BaseProcessor.cs index b692b9e5..dfcb6717 100644 --- a/MPF.Processors/BaseProcessor.cs +++ b/MPF.Processors/BaseProcessor.cs @@ -7,7 +7,6 @@ using System.IO.Compression; using System.Linq; using System.Text.RegularExpressions; using MPF.Core; -using MPF.Core.Utilities; using SabreTools.RedumpLib.Data; namespace MPF.Processors diff --git a/MPF.Processors/CleanRip.cs b/MPF.Processors/CleanRip.cs index 5535f896..1cd956fb 100644 --- a/MPF.Processors/CleanRip.cs +++ b/MPF.Processors/CleanRip.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; using MPF.Core; -using MPF.Core.Utilities; using SabreTools.Hashing; using SabreTools.Models.Logiqx; using SabreTools.RedumpLib; @@ -66,8 +65,7 @@ namespace MPF.Processors info = Builder.EnsureAllSections(info); // TODO: Determine if there's a CleanRip version anywhere - info.DumpingInfo!.DumpingProgram = EnumExtensions.LongName(InternalProgram.CleanRip); - info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + "-dumpinfo.txt")?.ToString("yyyy-MM-dd HH:mm:ss"); + info.DumpingInfo!.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + "-dumpinfo.txt")?.ToString("yyyy-MM-dd HH:mm:ss"); // Get the Datafile information var datafile = GenerateCleanripDatafile(basePath + ".iso", basePath + "-dumpinfo.txt"); diff --git a/MPF.Processors/DiscImageCreator.cs b/MPF.Processors/DiscImageCreator.cs index 0bff3e93..86ac5e53 100644 --- a/MPF.Processors/DiscImageCreator.cs +++ b/MPF.Processors/DiscImageCreator.cs @@ -296,7 +296,8 @@ namespace MPF.Processors // Get the dumping program and version var (dicCmd, dicVersion) = GetCommandFilePathAndVersion(basePath); - info.DumpingInfo!.DumpingProgram = $"{EnumExtensions.LongName(InternalProgram.DiscImageCreator)} {dicVersion ?? "Unknown Version"}"; + info.DumpingInfo!.DumpingProgram ??= string.Empty; + info.DumpingInfo.DumpingProgram += $" {dicVersion ?? "Unknown Version"}"; info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate(dicCmd)?.ToString("yyyy-MM-dd HH:mm:ss"); // Fill in the hardware data diff --git a/MPF.Processors/PS3CFW.cs b/MPF.Processors/PS3CFW.cs index 3c757567..1df49399 100644 --- a/MPF.Processors/PS3CFW.cs +++ b/MPF.Processors/PS3CFW.cs @@ -60,7 +60,8 @@ namespace MPF.Processors // Ensure that required sections exist info = Builder.EnsureAllSections(info); - info.DumpingInfo!.DumpingProgram = EnumExtensions.LongName(InternalProgram.PS3CFW); + // TODO: Determine if there's a CFW version anywhere + info.DumpingInfo!.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + ".iso")?.ToString("yyyy-MM-dd HH:mm:ss"); // Get the Datafile information Datafile? datafile = GeneratePS3CFWDatafile(basePath + ".iso"); diff --git a/MPF.Processors/Redumper.cs b/MPF.Processors/Redumper.cs index dbab9d65..5750ff19 100644 --- a/MPF.Processors/Redumper.cs +++ b/MPF.Processors/Redumper.cs @@ -178,7 +178,8 @@ namespace MPF.Processors info = Builder.EnsureAllSections(info); // Get the dumping program and version - info.DumpingInfo!.DumpingProgram = $"{EnumExtensions.LongName(InternalProgram.Redumper)} {GetVersion($"{basePath}.log") ?? "Unknown Version"}"; + info.DumpingInfo!.DumpingProgram ??= string.Empty; + info.DumpingInfo.DumpingProgram += $" {GetVersion($"{basePath}.log") ?? "Unknown Version"}"; info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate($"{basePath}.log")?.ToString("yyyy-MM-dd HH:mm:ss"); // Fill in the hardware data diff --git a/MPF.Processors/UmdImageCreator.cs b/MPF.Processors/UmdImageCreator.cs index 5a20515d..1c157559 100644 --- a/MPF.Processors/UmdImageCreator.cs +++ b/MPF.Processors/UmdImageCreator.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using MPF.Core; -using MPF.Core.Utilities; using SabreTools.Hashing; using SabreTools.Models.Logiqx; using SabreTools.RedumpLib; @@ -76,8 +75,7 @@ namespace MPF.Processors info = Builder.EnsureAllSections(info); // TODO: Determine if there's a UMDImageCreator version anywhere - info.DumpingInfo!.DumpingProgram = EnumExtensions.LongName(InternalProgram.UmdImageCreator); - info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + "_disc.txt")?.ToString("yyyy-MM-dd HH:mm:ss"); + info.DumpingInfo!.DumpingDate = ProcessingTool.GetFileModifiedDate(basePath + "_disc.txt")?.ToString("yyyy-MM-dd HH:mm:ss"); // Fill in the volume labels if (GetVolumeLabels($"{basePath}_volDesc.txt", out var volLabels)) diff --git a/MPF.Processors/XboxBackupCreator.cs b/MPF.Processors/XboxBackupCreator.cs index fe77c20a..17044f4d 100644 --- a/MPF.Processors/XboxBackupCreator.cs +++ b/MPF.Processors/XboxBackupCreator.cs @@ -93,7 +93,8 @@ namespace MPF.Processors return; // XBC dump info - info.DumpingInfo!.DumpingProgram = $"{EnumExtensions.LongName(InternalProgram.XboxBackupCreator)} {GetVersion(logPath) ?? "Unknown Version"}"; + info.DumpingInfo!.DumpingProgram ??= string.Empty; + info.DumpingInfo.DumpingProgram += $" {GetVersion(logPath) ?? "Unknown Version"}"; info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate(logPath)?.ToString("yyyy-MM-dd HH:mm:ss"); info.DumpingInfo.Model = GetDrive(logPath) ?? "Unknown Drive";