Migrate to Blazor WASM, MSSQL platform DB, and durable audio PVC.
build-and-deploy / deploy (push) Failing after 15m11s
build-and-deploy / deploy (push) Failing after 15m11s
Remove in-cluster Postgres; serve WASM via nginx; add audio import job for Gooya archives.
This commit is contained in:
@@ -56,23 +56,33 @@ public static class TafsirEndpoints
|
||||
return Results.Ok(detail);
|
||||
});
|
||||
|
||||
group.MapGet("/audio/{episodeId:guid}", async (Guid episodeId, AppDbContext db, IWebHostEnvironment env, CancellationToken ct) =>
|
||||
group.MapGet("/audio/{episodeId:guid}", async (Guid episodeId, AppDbContext db, IConfiguration config, IWebHostEnvironment env, CancellationToken ct) =>
|
||||
{
|
||||
var episode = await db.Episodes.AsNoTracking().FirstOrDefaultAsync(e => e.Id == episodeId, ct);
|
||||
if (episode is null) return Results.NotFound();
|
||||
|
||||
var relative = episode.AudioUrl.TrimStart('/');
|
||||
var path = Path.Combine(env.ContentRootPath, "wwwroot", relative);
|
||||
if (!File.Exists(path))
|
||||
var audioRoot = config["AudioRoot"] ?? "/data/audio";
|
||||
var relative = episode.AudioUrl.TrimStart('/').Replace('\\', '/');
|
||||
|
||||
// Prefer PVC mount; fallback to wwwroot for local sample files
|
||||
var candidates = new[]
|
||||
{
|
||||
// Fallback placeholder: return empty audio-friendly response path for demo
|
||||
var placeholder = Path.Combine(env.ContentRootPath, "wwwroot", "audio", "silence.mp3");
|
||||
if (File.Exists(placeholder))
|
||||
return Results.File(placeholder, "audio/mpeg", enableRangeProcessing: true);
|
||||
return Results.NotFound();
|
||||
Path.Combine(audioRoot, relative),
|
||||
Path.Combine(env.ContentRootPath, "wwwroot", relative),
|
||||
Path.Combine(env.ContentRootPath, "wwwroot", "audio", Path.GetFileName(relative))
|
||||
};
|
||||
|
||||
foreach (var path in candidates)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
return Results.File(path, "audio/mpeg", enableRangeProcessing: true);
|
||||
}
|
||||
|
||||
return Results.File(path, "audio/mpeg", enableRangeProcessing: true);
|
||||
var silence = Path.Combine(env.ContentRootPath, "wwwroot", "audio", "silence.mp3");
|
||||
if (File.Exists(silence))
|
||||
return Results.File(silence, "audio/mpeg", enableRangeProcessing: true);
|
||||
|
||||
return Results.NotFound();
|
||||
});
|
||||
|
||||
return group;
|
||||
|
||||
Reference in New Issue
Block a user