feat(bake): publish validated pak artifacts atomically
This commit is contained in:
parent
90b378cc70
commit
999201cca7
9 changed files with 362 additions and 14 deletions
39
src/AcDream.Bake/BakeArtifactValidator.cs
Normal file
39
src/AcDream.Bake/BakeArtifactValidator.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using AcDream.Content.Pak;
|
||||
|
||||
namespace AcDream.Bake;
|
||||
|
||||
/// <summary>Strict pre-publication validation for one completed bake artifact.</summary>
|
||||
public static class BakeArtifactValidator
|
||||
{
|
||||
public static void Validate(
|
||||
string path,
|
||||
in PakHeader expectedHeader,
|
||||
int expectedTocCount)
|
||||
{
|
||||
using var reader = new PakReader(path);
|
||||
var actual = reader.Header;
|
||||
|
||||
if (actual.FormatVersion != PakFormat.CurrentFormatVersion)
|
||||
throw new InvalidDataException(
|
||||
$"bake format version {actual.FormatVersion} does not match " +
|
||||
$"{PakFormat.CurrentFormatVersion}");
|
||||
if (actual.BakeToolVersion != PakFormat.CurrentBakeToolVersion)
|
||||
throw new InvalidDataException(
|
||||
$"bake tool version {actual.BakeToolVersion} does not match " +
|
||||
$"{PakFormat.CurrentBakeToolVersion}");
|
||||
if (actual.PortalIteration != expectedHeader.PortalIteration ||
|
||||
actual.CellIteration != expectedHeader.CellIteration ||
|
||||
actual.HighResIteration != expectedHeader.HighResIteration ||
|
||||
actual.LanguageIteration != expectedHeader.LanguageIteration)
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
"bake DAT iterations do not match the source collection");
|
||||
}
|
||||
if (actual.TocCount != checked((uint)expectedTocCount))
|
||||
throw new InvalidDataException(
|
||||
$"bake TOC count {actual.TocCount} does not match expected " +
|
||||
$"{expectedTocCount}");
|
||||
|
||||
reader.ValidateComplete();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue