Skip to content

Commit

Permalink
Add runtime error for improperly created artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski committed Aug 23, 2024
1 parent 9dddf1c commit 66fc36f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- Add unused passable func to OutputFile
- Pass in new func for OutputFile
- Use new func in Redumper
- Add runtime error for improperly created artifacts

### 3.2.1 (2024-08-05)

Expand Down
10 changes: 8 additions & 2 deletions MPF.Processors/OutputFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public bool IsZippable
/// </summary>
private readonly Func<string, bool>? _existsFunc;

// TODO: Add validation that a key exists if the artifact flag is present

/// <summary>
/// Create an OutputFile with a single filename
/// </summary>
Expand All @@ -169,6 +167,10 @@ public OutputFile(string[] filenames, OutputFileFlags flags, Func<string, bool>?
ArtifactKey = null;
_flags = flags;
_existsFunc = existsFunc;

// Ensure artifacts have a key
if (IsArtifact && string.IsNullOrEmpty(ArtifactKey))
throw new InvalidDataException($"{flags} should not contain the Artifact or Binary flag");
}

/// <summary>
Expand All @@ -180,6 +182,10 @@ public OutputFile(string[] filenames, OutputFileFlags flags, string artifactKey,
ArtifactKey = artifactKey;
_flags = flags;
_existsFunc = existsFunc;

// Ensure artifacts have a key
if (IsArtifact && string.IsNullOrEmpty(ArtifactKey))
throw new InvalidDataException($"{flags} should not contain the Artifact or Binary flag");
}

/// <summary>
Expand Down

0 comments on commit 66fc36f

Please sign in to comment.