mirror of
https://github.com/alexhopeoconnor/bom-local-service.git
synced 2026-10-04 03:28:11 +10:00
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:
@@ -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(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user