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,38 @@
|
||||
using Amazon.Runtime;
|
||||
using Amazon.S3;
|
||||
using Houston.Settings;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Houston.Extensions;
|
||||
|
||||
public static class DocumentsExtensions
|
||||
{
|
||||
extension(IServiceCollection services)
|
||||
{
|
||||
public IServiceCollection AddDocumentsClient()
|
||||
{
|
||||
return services.AddKeyedScoped<IAmazonS3>("Documents", (services, _) =>
|
||||
{
|
||||
var settings = services.GetRequiredService<IOptions<DocumentsSettings>>();
|
||||
var client = new AmazonS3Client(
|
||||
new BasicAWSCredentials(settings.Value.S3.Key, settings.Value.S3.Secret),
|
||||
new AmazonS3Config { ServiceURL = settings.Value.S3.Endpoint });
|
||||
|
||||
// The SDK percent-encodes the separators in x-amz-copy-source ("bucket%2Fkey%2Fdoc.pdf").
|
||||
// AWS decodes that again, our S3 splits bucket and key on the first literal slash and ends up
|
||||
// without a key ("Invalid copy source object key"), so the separators are restored here. The
|
||||
// event runs before the signer, hence the corrected value is the one that gets signed.
|
||||
client.BeforeRequestEvent += (_, args) =>
|
||||
{
|
||||
if (args is WebServiceRequestEventArgs { Headers: { } headers }
|
||||
&& headers.TryGetValue("x-amz-copy-source", out var copySource)
|
||||
&& copySource.Contains("%2F", StringComparison.Ordinal))
|
||||
{
|
||||
headers["x-amz-copy-source"] = copySource.Replace("%2F", "/", StringComparison.Ordinal);
|
||||
}
|
||||
};
|
||||
|
||||
return client;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user