From 0fc53cb53411bc3e94835c7782d2c0da91bd3566 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 22 Aug 2024 14:46:50 -0400 Subject: [PATCH] Define new ArtifactKey field --- CHANGELIST.md | 1 + MPF.Processors/BaseProcessor.cs | 6 +++--- MPF.Processors/OutputFile.cs | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index d068b53f..ab4625e2 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -38,6 +38,7 @@ - Replace GetLogFilePaths with common code - Move GetLogFilePaths to better location - Replace GenerateArtifacts with common code +- Define new ArtifactKey field ### 3.2.1 (2024-08-05) diff --git a/MPF.Processors/BaseProcessor.cs b/MPF.Processors/BaseProcessor.cs index 2e34e0ab..eb15a377 100644 --- a/MPF.Processors/BaseProcessor.cs +++ b/MPF.Processors/BaseProcessor.cs @@ -75,7 +75,7 @@ namespace MPF.Processors foreach (var outputFile in outputFiles) { // Skip non-artifact files - if (!outputFile.IsArtifact) + if (!outputFile.IsArtifact || outputFile.ArtifactKey == null) continue; // Skip non-existent files @@ -91,13 +91,13 @@ namespace MPF.Processors { byte[] data = File.ReadAllBytes(filename); string str = Convert.ToBase64String(data); - info.Artifacts!.Add(filename, str); + info.Artifacts!.Add(outputFile.ArtifactKey, str); } else { string? data = ProcessingTool.GetFullFile(filename); string str = ProcessingTool.GetBase64(data) ?? string.Empty; - info.Artifacts!.Add(filename, str); + info.Artifacts!.Add(outputFile.ArtifactKey, str); } break; diff --git a/MPF.Processors/OutputFile.cs b/MPF.Processors/OutputFile.cs index 7f8f9a85..6150f84d 100644 --- a/MPF.Processors/OutputFile.cs +++ b/MPF.Processors/OutputFile.cs @@ -50,6 +50,11 @@ namespace MPF.Processors /// public string[] Filenames { get; private set; } + /// + /// Key used when creating an artifact + /// + public string? ArtifactKey { get; private set;} + /// /// Indicates if the file is required /// @@ -132,12 +137,25 @@ namespace MPF.Processors /// private readonly OutputFileFlags _flags; + // TODO: Add validation that a key exists if the artifact flag is present + /// /// Create an OutputFile with a single filename /// public OutputFile(string filename, OutputFileFlags flags) { Filenames = [filename]; + ArtifactKey = null; + _flags = flags; + } + + /// + /// Create an OutputFile with a single filename + /// + public OutputFile(string filename, OutputFileFlags flags, string artifactKey) + { + Filenames = [filename]; + ArtifactKey = artifactKey; _flags = flags; } @@ -147,6 +165,17 @@ namespace MPF.Processors public OutputFile(string[] filenames, OutputFileFlags flags) { Filenames = filenames; + ArtifactKey = null; + _flags = flags; + } + + /// + /// Create an OutputFile with set of filenames + /// + public OutputFile(string[] filenames, OutputFileFlags flags, string artifactKey) + { + Filenames = filenames; + ArtifactKey = artifactKey; _flags = flags; }