Refactor downloads to use job-specific subdirectories

Organize downloaded files into per-job subdirectories under "downloads" instead of a flat structure. Update DownloadController and VideoService to read, write, and delete files within these job-specific directories. Add helper methods for directory management and improve logging. Update download/delete endpoints and result URLs to reflect the new structure. Clean up empty job directories after file deletion.
This commit is contained in:
Michal Vrba
2025-12-14 11:04:46 +01:00
parent 7c99721174
commit 2d2e855202
14 changed files with 1073 additions and 66 deletions
+5 -2
View File
@@ -10,6 +10,7 @@ builder.Services.AddHttpClient();
// Register services
builder.Services.AddScoped<IVideoService, VideoService>();
builder.Services.AddSingleton<ISessionService, SessionService>(); // Register session service as singleton
// Add CORS for Blazor WebAssembly client
builder.Services.AddCors(options =>
@@ -64,6 +65,7 @@ app.MapGet("/", (IWebHostEnvironment env) => new
check_status = "/api/video/status/{jobId}",
get_result = "/api/video/result/{jobId}",
download = "/api/download/{jobId}",
download_by_session = "/api/download/{sessionId}/{jobId}",
static_files = "/downloads/{fileName}",
openapi = "/openapi/v1.json"
},
@@ -80,10 +82,11 @@ app.MapControllers();
app.Logger.LogInformation("?? TuneRipper API is starting...");
app.Logger.LogInformation("?? Environment: {Environment}", app.Environment.EnvironmentName);
app.Logger.LogInformation("?? API will be available at:");
app.Logger.LogInformation(" • HTTPS: https://localhost:7160");
app.Logger.LogInformation(" • HTTP: http://localhost:5112");
app.Logger.LogInformation(" ?? HTTPS: https://localhost:7160");
app.Logger.LogInformation(" ?? HTTP: http://localhost:5112");
app.Logger.LogInformation("?? Health check: /api/health");
app.Logger.LogInformation("?? API info: /");
app.Logger.LogInformation("?? Static files served from: /downloads/*");
app.Logger.LogInformation("?? Session-based downloads supported");
app.Run();