Refactor cache validation and add startup cleanup

- Move cache folder completeness check to CacheHelper utility
- Replace Width with RightOffset in screenshot crop config
- Add startup cleanup to remove incomplete cache folders
- Validate cache folders before use in BomRadarService
This commit is contained in:
2025-12-07 14:35:38 +10:00
parent 18e0a7a01f
commit 27dd44aaa1
9 changed files with 196 additions and 34 deletions
+9
View File
@@ -47,6 +47,15 @@ if (enableHttpsRedirection)
// No authorization required - service is designed to run behind a reverse proxy if auth is needed
app.MapControllers();
// Cleanup incomplete cache folders from previous crashes/restarts before starting services
var cacheService = app.Services.GetRequiredService<ICacheService>();
var deletedCount = cacheService.CleanupIncompleteCacheFolders();
if (deletedCount > 0)
{
var logger = app.Services.GetRequiredService<ILogger<Program>>();
logger.LogInformation("Startup recovery: cleaned up {Count} incomplete cache folder(s) from previous session", deletedCount);
}
// Cleanup on shutdown
app.Lifetime.ApplicationStopped.Register(() =>
{