Files
git.stella-ops.org/src/AirGap/__Libraries/StellaOps.AirGap.Bundle/Services/SnapshotBundleWriter.Sections.TrustRoots.cs
2026-02-04 19:59:20 +02:00

42 lines
1.3 KiB
C#

using StellaOps.AirGap.Bundle.Models;
namespace StellaOps.AirGap.Bundle.Services;
public sealed partial class SnapshotBundleWriter
{
private static async Task WriteTrustRootsAsync(
SnapshotBundleRequest request,
string tempDir,
List<BundleEntry> entries,
KnowledgeSnapshotManifest manifest,
CancellationToken cancellationToken)
{
if (request.TrustRoots is not { Count: > 0 })
{
return;
}
var trustDir = Path.Combine(tempDir, "trust");
Directory.CreateDirectory(trustDir);
foreach (var trustRoot in request.TrustRoots)
{
var filePath = Path.Combine(trustDir, trustRoot.FileName);
await File.WriteAllBytesAsync(filePath, trustRoot.Content, cancellationToken).ConfigureAwait(false);
var relativePath = $"trust/{trustRoot.FileName}";
var digest = AddEntry(entries, relativePath, trustRoot.Content);
manifest.TrustRoots.Add(new TrustRootSnapshotEntry
{
KeyId = trustRoot.KeyId,
RelativePath = relativePath,
Digest = digest,
SizeBytes = trustRoot.Content.Length,
Algorithm = trustRoot.Algorithm,
ExpiresAt = trustRoot.ExpiresAt
});
}
}
}