feat: make storage tier thresholds configurable in system settings
Add StorageGreenThresholdPercent (default 30%) and StorageRedThresholdPercent (default 10%) to both SystemSettingsDto and the settings UI. StorageGuardService now reads thresholds from settings instead of hardcoding. Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
This commit is contained in:
co-authored by
Claude Opus 4.8 noreply@anthropic.com
parent
f5ad1dec00
commit
0831b33ea0
@@ -7,8 +7,6 @@ namespace LiveRecorder.Infrastructure.Services;
|
||||
public sealed class StorageGuardService : IStorageGuardService
|
||||
{
|
||||
private const long Megabyte = 1024L * 1024L;
|
||||
private const double GreenThresholdPercent = 30.0;
|
||||
private const double YellowThresholdPercent = 10.0;
|
||||
private readonly ILogger<StorageGuardService> _logger;
|
||||
|
||||
public StorageGuardService(ILogger<StorageGuardService> logger)
|
||||
@@ -46,13 +44,16 @@ public sealed class StorageGuardService : IStorageGuardService
|
||||
var usagePercent = totalBytes > 0 ? (double)usedBytes / totalBytes * 100.0 : 0;
|
||||
var freePercent = 100.0 - usagePercent;
|
||||
|
||||
// Determine tier
|
||||
// Determine tier using configurable thresholds
|
||||
var greenThreshold = Math.Clamp(settings.StorageGreenThresholdPercent, 5, 90);
|
||||
var redThreshold = Math.Clamp(settings.StorageRedThresholdPercent, 1, greenThreshold - 1);
|
||||
|
||||
StorageTier tier;
|
||||
if (freePercent >= GreenThresholdPercent)
|
||||
if (freePercent >= greenThreshold)
|
||||
{
|
||||
tier = StorageTier.Green;
|
||||
}
|
||||
else if (freePercent >= YellowThresholdPercent)
|
||||
else if (freePercent >= redThreshold)
|
||||
{
|
||||
tier = StorageTier.Yellow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user