mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Replace GenerateArtifacts with common code
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
- Hook up GetOutputFiles in debug way
|
||||
- Replace GetLogFilePaths with common code
|
||||
- Move GetLogFilePaths to better location
|
||||
- Replace GenerateArtifacts with common code
|
||||
|
||||
### 3.2.1 (2024-08-05)
|
||||
|
||||
|
||||
@@ -88,25 +88,6 @@ namespace MPF.Processors
|
||||
return (!missingFiles.Any(), missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists(basePath + ".cicm.xml"))
|
||||
info.Artifacts["cicm"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(basePath + ".cicm.xml")) ?? string.Empty;
|
||||
if (File.Exists(basePath + ".ibg"))
|
||||
info.Artifacts["ibg"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".ibg"));
|
||||
if (File.Exists(basePath + ".log"))
|
||||
info.Artifacts["log"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(basePath + ".log")) ?? string.Empty;
|
||||
if (File.Exists(basePath + ".mhddlog.bin"))
|
||||
info.Artifacts["mhddlog_bin"] = Convert.ToBase64String(File.ReadAllBytes(basePath + ".mhddlog.bin"));
|
||||
if (File.Exists(basePath + ".resume.xml"))
|
||||
info.Artifacts["resume"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(basePath + ".resume.xml")) ?? string.Empty;
|
||||
if (File.Exists(basePath + ".sub.log"))
|
||||
info.Artifacts["sub_log"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(basePath + ".sub.log")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -55,9 +55,57 @@ namespace MPF.Processors
|
||||
/// <summary>
|
||||
/// Generate artifacts and add to the SubmissionInfo
|
||||
/// </summary>
|
||||
/// <param name="submissionInfo">Base submission info to fill in specifics for</param>
|
||||
/// <param name="info">Base submission info to fill in specifics for</param>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
public abstract void GenerateArtifacts(SubmissionInfo submissionInfo, string basePath);
|
||||
public void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
// Get the base filename and directory from the base path
|
||||
string baseFilename = Path.GetFileName(basePath);
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
|
||||
// Get the list of output files
|
||||
var outputFiles = GetOutputFiles(baseFilename);
|
||||
if (outputFiles.Count == 0)
|
||||
return;
|
||||
|
||||
// Ensure the artifacts dictionary exists
|
||||
info.Artifacts ??= [];
|
||||
|
||||
// Only try to create artifacts for files that exist
|
||||
foreach (var outputFile in outputFiles)
|
||||
{
|
||||
// Skip non-artifact files
|
||||
if (!outputFile.IsArtifact)
|
||||
continue;
|
||||
|
||||
// Skip non-existent files
|
||||
foreach (string filename in outputFile.Filenames)
|
||||
{
|
||||
string outputFilePath = Path.Combine(baseDirectory, filename);
|
||||
if (!File.Exists(outputFilePath))
|
||||
continue;
|
||||
|
||||
// TODO: Determine a better way of getting the artifact key
|
||||
// Get binary artifacts as a byte array
|
||||
if (outputFile.IsBinaryArtifact)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(filename);
|
||||
string str = Convert.ToBase64String(data);
|
||||
info.Artifacts!.Add(filename, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
string? data = ProcessingTool.GetFullFile(filename);
|
||||
string str = ProcessingTool.GetBase64(data) ?? string.Empty;
|
||||
info.Artifacts!.Add(filename, str);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a SubmissionInfo for the output files
|
||||
|
||||
@@ -55,17 +55,6 @@ namespace MPF.Processors
|
||||
return (!missingFiles.Any(), missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists(basePath + ".bca"))
|
||||
info.Artifacts["bca"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(basePath + ".bca", binary: true)) ?? string.Empty;
|
||||
if (File.Exists(basePath + "-dumpinfo.txt"))
|
||||
info.Artifacts["dumpinfo"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(basePath + "-dumpinfo.txt")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -235,63 +235,6 @@ namespace MPF.Processors
|
||||
return (!missingFiles.Any(), missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
//if (File.Exists($"{basePath}.c2"))
|
||||
// info.Artifacts["c2"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}.c2")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_c2Error.txt"))
|
||||
info.Artifacts["c2Error"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_c2Error.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.ccd"))
|
||||
info.Artifacts["ccd"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.ccd")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_cmd.txt")) // TODO: Figure out how to read in the timestamp-named file
|
||||
info.Artifacts["cmd"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_cmd.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_CSSKey.txt"))
|
||||
info.Artifacts["csskey"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_CSSKey.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.cue"))
|
||||
info.Artifacts["cue"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.cue")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.dat"))
|
||||
info.Artifacts["dat"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.dat")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_disc.txt"))
|
||||
info.Artifacts["disc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_disc.txt")) ?? string.Empty;
|
||||
//if (File.Exists(Path.Combine(outputDirectory, $"{basePath}_DMI.bin")))
|
||||
// info.Artifacts["dmi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(outputDirectory, $"{basePath}_DMI.bin"))) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_drive.txt"))
|
||||
info.Artifacts["drive"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_drive.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_img.cue"))
|
||||
info.Artifacts["img_cue"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_img.cue")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.img_EdcEcc.txt"))
|
||||
info.Artifacts["img_EdcEcc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.img_EdcEcc.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.img_EccEdc.txt"))
|
||||
info.Artifacts["img_EdcEcc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.img_EccEdc.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_mainError.txt"))
|
||||
info.Artifacts["mainError"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_mainError.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_mainInfo.txt"))
|
||||
info.Artifacts["mainInfo"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_mainInfo.txt")) ?? string.Empty;
|
||||
//if (File.Exists($"{basePath}_PFI.bin"))
|
||||
// info.Artifacts["pfi"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}_PFI.bin")) ?? string.Empty;
|
||||
//if (File.Exists($"{basePath}_PIC.bin"))
|
||||
// info.Artifacts["pic"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}_PIC.bin")) ?? string.Empty;
|
||||
//if (File.Exists($"{basePath}_SS.bin"))
|
||||
// info.Artifacts["ss"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}_SS.bin")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.sub"))
|
||||
info.Artifacts["sub"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}.sub")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_subError.txt"))
|
||||
info.Artifacts["subError"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_subError.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_subInfo.txt"))
|
||||
info.Artifacts["subInfo"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_subInfo.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_subIntention.txt"))
|
||||
info.Artifacts["subIntention"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_subIntention.txt")) ?? string.Empty;
|
||||
//if (File.Exists($"{basePath}_sub.txt"))
|
||||
// info.Artifacts["subReadable"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_sub.txt")) ?? string.Empty;
|
||||
//if (File.Exists($"{basePath}_subReadable.txt"))
|
||||
// info.Artifacts["subReadable"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_subReadable.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_volDesc.txt"))
|
||||
info.Artifacts["volDesc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_volDesc.txt")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -48,19 +48,6 @@ namespace MPF.Processors
|
||||
return (missingFiles.Count == 0, missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
string? getKeyBasePath = GetCFWBasePath(basePath);
|
||||
|
||||
if (File.Exists(getKeyBasePath + ".disc.pic"))
|
||||
info.Artifacts["discpic"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(getKeyBasePath + ".disc.pic", binary: true)) ?? string.Empty;
|
||||
if (File.Exists(getKeyBasePath + ".getkey.log"))
|
||||
info.Artifacts["getkeylog"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(getKeyBasePath + ".getkey.log")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -144,57 +144,6 @@ namespace MPF.Processors
|
||||
return (!missingFiles.Any(), missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists($"{basePath}.asus"))
|
||||
info.Artifacts["asus"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.asus")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.atip"))
|
||||
info.Artifacts["atip"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.atip")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.cdtext"))
|
||||
info.Artifacts["cdtext"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.cdtext")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.cue"))
|
||||
info.Artifacts["cue"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.cue")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.fulltoc"))
|
||||
info.Artifacts["fulltoc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.fulltoc")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.hash"))
|
||||
info.Artifacts["hash"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.hash")) ?? string.Empty;
|
||||
// TODO: "{basePath} (Track X).hash" (get from cuesheet)
|
||||
if (File.Exists($"{basePath}.log"))
|
||||
info.Artifacts["log"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.log")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.manufacturer"))
|
||||
info.Artifacts["manufacturer"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.manufacturer")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.1.manufacturer"))
|
||||
info.Artifacts["manufacturer1"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.1.manufacturer")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.2.manufacturer"))
|
||||
info.Artifacts["manufacturer2"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.2.manufacturer")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.physical"))
|
||||
info.Artifacts["physical"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.physical")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.0.physical"))
|
||||
info.Artifacts["physical0"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.0.physical")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.1.physical"))
|
||||
info.Artifacts["physical1"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.1.physical")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.2.physical"))
|
||||
info.Artifacts["physical2"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.2.physical")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.pma"))
|
||||
info.Artifacts["pma"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.pma")) ?? string.Empty;
|
||||
// if (File.Exists($"{basePath}.skeleton"))
|
||||
// info.Artifacts["skeleton"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.skeleton")) ?? string.Empty;
|
||||
// // Also: "{basePath} (Track X).skeleton" (get from cuesheet)
|
||||
// if (File.Exists($"{basePath}.scram"))
|
||||
// info.Artifacts["scram"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.scram")) ?? string.Empty;
|
||||
// if (File.Exists($"{basePath}.scrap"))
|
||||
// info.Artifacts["scrap"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.scrap")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.state"))
|
||||
info.Artifacts["state"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.state")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.subcode"))
|
||||
info.Artifacts["subcode"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.subcode")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.toc"))
|
||||
info.Artifacts["toc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.toc")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -57,25 +57,6 @@ namespace MPF.Processors
|
||||
return (!missingFiles.Any(), missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists($"{basePath}_disc.txt"))
|
||||
info.Artifacts["disc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_disc.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_drive.txt"))
|
||||
info.Artifacts["drive"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_drive.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_mainError.txt"))
|
||||
info.Artifacts["mainError"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_mainError.txt")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_mainInfo.txt"))
|
||||
info.Artifacts["mainInfo"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_mainInfo.txt")) ?? string.Empty;
|
||||
//if (File.Exists($"{basePath}_PFI.bin"))
|
||||
// info.Artifacts["pfi"] = Convert.ToBase64String(File.ReadAllBytes($"{basePath}_PFI.bin")) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}_volDesc.txt"))
|
||||
info.Artifacts["volDesc"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}_volDesc.txt")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -65,29 +65,6 @@ namespace MPF.Processors
|
||||
return (!missingFiles.Any(), missingFiles);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateArtifacts(SubmissionInfo info, string basePath)
|
||||
{
|
||||
info.Artifacts ??= [];
|
||||
|
||||
string baseDir = Path.GetDirectoryName(basePath) + Path.DirectorySeparatorChar;
|
||||
string? logPath = GetLogName(baseDir);
|
||||
|
||||
if (File.Exists(logPath))
|
||||
info.Artifacts["log"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile(logPath!)) ?? string.Empty;
|
||||
if (File.Exists($"{basePath}.dvd"))
|
||||
info.Artifacts["dvd"] = ProcessingTool.GetBase64(ProcessingTool.GetFullFile($"{basePath}.dvd")) ?? string.Empty;
|
||||
//if (File.Exists(Path.Combine(baseDirectory, "DMI.bin"))
|
||||
// info.Artifacts["dmi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(baseDirectory, "DMI.bin")) ?? string.Empty;
|
||||
// TODO: Include PFI artifact only if the hash doesn't match known PFI hashes
|
||||
//if (File.Exists(Path.Combine(baseDirectory, "PFI.bin"))
|
||||
// info.Artifacts["pfi"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(baseDirectory, "PFI.bin")) ?? string.Empty;
|
||||
//if (File.Exists(Path.Combine(baseDirectory, "SS.bin"))
|
||||
// info.Artifacts["ss"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(baseDirectory, "SS.bin")) ?? string.Empty;
|
||||
//if (File.Exists(Path.Combine(baseDirectory, "RawSS.bin"))
|
||||
// info.Artifacts["rawss"] = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(baseDirectory, "RawSS.bin")) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user