Centralize dumping program information gathering

This commit is contained in:
Matt Nadareski
2024-05-28 10:34:33 -04:00
parent c9a67b1b51
commit 91a0e85e24
10 changed files with 39 additions and 16 deletions

View File

@@ -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)

View File

@@ -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
/// <summary>
/// Creates a default SubmissionInfo object based on the current system and media type
/// </summary>
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;
}
/// <summary>
/// Get the dumping program name from the processor
/// </summary>
/// <param name="processor"></param>
/// <returns></returns>
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();
}
/// <summary>
/// Formats a list of volume labels and their corresponding filesystems
/// </summary>

View File

@@ -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");

View File

@@ -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

View File

@@ -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");

View File

@@ -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

View File

@@ -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");

View File

@@ -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

View File

@@ -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))

View File

@@ -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";