Files
0qln bff34658b8 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.
2026-08-25 21:38:22 +02:00

44 lines
1.4 KiB
C#

public async Task<string?> TryGetUrlFileIconClassAsync(DocumentKey doc, CancellationToken cancellationToken)
{
var ini = await TryReadUrlFileAsync(doc, cancellationToken);
var iconFile = ini?.GetValue("InternetShortcut", "IconFile");
return String.IsNullOrEmpty(iconFile) ? null : iconFile;
}
private async Task<string?> TryGetUrlFileTargetAsync(DocumentKey doc, CancellationToken cancellationToken)
{
var ini = await TryReadUrlFileAsync(doc, cancellationToken);
var target = ini?.GetValue("InternetShortcut", "URL");
if (String.IsNullOrWhiteSpace(target))
return null;
if (!Uri.TryCreate(target, UriKind.Absolute, out var uri))
return null;
if (!(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps))
return null;
return uri.ToString();
}
private async Task<IniDocument?> TryReadUrlFileAsync(DocumentKey doc, CancellationToken cancellationToken)
{
try
{
using var response = await s3.GetObjectAsync(new GetObjectRequest
{
BucketName = _settings.S3.Bucket,
Key = doc.ToString(),
}, cancellationToken);
using var reader = new StreamReader(response.ResponseStream);
return await iniParser.ParseAsync(reader, cancellationToken);
}
catch (AmazonS3Exception exception) when (exception.StatusCode == HttpStatusCode.NotFound)
{
return null;
}
}