appendix: 23 Code-Ausschnitte aus dem Houston-Repository
Pin nixpkgs to the revision used by itc.componentware: the channel version ships a latexminted that crashes on Python 3.14, which made every listing fail and sent latexmk into an endless error prompt. Also force nonstopmode/halt-on-error so a broken listing can never loop again.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/// <summary>
|
||||
/// Streams the prepared documents into a ZIP archive written directly onto <paramref name="destination"/>
|
||||
/// </summary>
|
||||
public async Task WriteZipArchiveAsync(
|
||||
OrgSlug orgSlug, IEnumerable<DocumentRelativePath> documents,
|
||||
Stream destination, CancellationToken cancellationToken)
|
||||
{
|
||||
await using var zip = await ZipArchive.CreateAsync(
|
||||
destination, ZipArchiveMode.Create, leaveOpen: true,
|
||||
entryNameEncoding: null, cancellationToken);
|
||||
|
||||
foreach (var path in documents)
|
||||
{
|
||||
var key = new DocumentKey(orgSlug, path.Type, path.Name);
|
||||
|
||||
using var response = await TryGetObjectAsync(new GetObjectRequest
|
||||
{
|
||||
BucketName = _settings.S3.Bucket,
|
||||
Key = key.ToString(),
|
||||
}, cancellationToken);
|
||||
|
||||
if (response is null)
|
||||
continue;
|
||||
|
||||
var entry = zip.CreateEntry(path.ToString(), CompressionLevel.Optimal);
|
||||
await using var entryStream = await entry.OpenAsync(cancellationToken);
|
||||
await response.ResponseStream.CopyToAsync(entryStream, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<GetObjectResponse?> TryGetObjectAsync(GetObjectRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await s3.GetObjectAsync(request, cancellationToken);
|
||||
}
|
||||
catch (AmazonS3Exception exception) when (exception.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user