mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 08:56:38 +00:00
cleanup
This commit is contained in:
@@ -318,6 +318,8 @@ public class RouteProcessingService : BackgroundService
|
||||
|
||||
await _routeRepository.UpdateRouteAsync(route);
|
||||
|
||||
await CleanupRegionFilesAsync(regionIds, cancellationToken);
|
||||
|
||||
_logger.LogInformation("Route {RouteId} maps processing completed successfully", routeId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -327,6 +329,53 @@ public class RouteProcessingService : BackgroundService
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CleanupRegionFilesAsync(IEnumerable<Guid> regionIds, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var regionId in regionIds)
|
||||
{
|
||||
var region = await _regionRepository.GetByIdAsync(regionId);
|
||||
if (region == null) continue;
|
||||
|
||||
if (!string.IsNullOrEmpty(region.CsvFilePath) && File.Exists(region.CsvFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(region.CsvFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete region CSV file: {FilePath}", region.CsvFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(region.SummaryFilePath) && File.Exists(region.SummaryFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(region.SummaryFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete region summary file: {FilePath}", region.SummaryFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
var readyDir = _storageConfig.ReadyDirectory;
|
||||
var stitchedImagePath = Path.Combine(readyDir, $"region_{regionId}_stitched.jpg");
|
||||
if (File.Exists(stitchedImagePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(stitchedImagePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete region stitched image: {FilePath}", stitchedImagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GenerateRouteCsvAsync(
|
||||
string filePath,
|
||||
IEnumerable<TileInfo> tiles,
|
||||
|
||||
Reference in New Issue
Block a user