diff --git a/MareSynchronosServer/MareSynchronosShared/Utils/StaticFilesServerConfiguration.cs b/MareSynchronosServer/MareSynchronosShared/Utils/StaticFilesServerConfiguration.cs index 6786d2d..a9ed59b 100644 --- a/MareSynchronosServer/MareSynchronosShared/Utils/StaticFilesServerConfiguration.cs +++ b/MareSynchronosServer/MareSynchronosShared/Utils/StaticFilesServerConfiguration.cs @@ -7,6 +7,7 @@ public class StaticFilesServerConfiguration : MareConfigurationBase { public bool IsDistributionNode { get; set; } = false; public Uri? MainFileServerAddress { get; set; } = null; + public Uri? DistributionFileServerAddress { get; set; } = null; public int ForcedDeletionOfFilesAfterHours { get; set; } = -1; public double CacheSizeHardLimitInGiB { get; set; } = -1; public int UnusedFileRetentionPeriodInDays { get; set; } = 14; @@ -15,6 +16,7 @@ public class StaticFilesServerConfiguration : MareConfigurationBase public int DownloadTimeoutSeconds { get; set; } = 5; public int DownloadQueueReleaseSeconds { get; set; } = 15; public int DownloadQueueClearLimit { get; set; } = 15000; + public int CleanupCheckInMinutes { get; set; } = 15; [RemoteConfiguration] public Uri CdnFullUrl { get; set; } = null; [RemoteConfiguration] diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs index d6d7c5e..ddf84c3 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs @@ -30,7 +30,7 @@ public sealed class CachedFileProvider : IDisposable _fileStatisticsService = fileStatisticsService; _metrics = metrics; _generator = generator; - _remoteCacheSourceUri = configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.MainFileServerAddress), null); + _remoteCacheSourceUri = configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.DistributionFileServerAddress), null); _isDistributionServer = configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.IsDistributionNode), false); _basePath = configuration.GetValue(nameof(StaticFilesServerConfiguration.CacheDirectory)); _httpClient = new(); diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/MainFileCleanupService.cs b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/MainFileCleanupService.cs index c360799..6239e2d 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/MainFileCleanupService.cs +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/MainFileCleanupService.cs @@ -17,7 +17,8 @@ public class MainFileCleanupService : IHostedService private readonly IServiceProvider _services; private CancellationTokenSource _cleanupCts; - public MainFileCleanupService(MareMetrics metrics, ILogger logger, IServiceProvider services, IConfigurationService configuration) + public MainFileCleanupService(MareMetrics metrics, ILogger logger, + IServiceProvider services, IConfigurationService configuration) { _metrics = metrics; _logger = logger; @@ -54,11 +55,11 @@ public class MainFileCleanupService : IHostedService { _logger.LogError(e, "Error during cleanup task"); } - + var cleanupCheckMinutes = _configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.CleanupCheckInMinutes), 15); var now = DateTime.Now; TimeOnly currentTime = new(now.Hour, now.Minute, now.Second); - TimeOnly futureTime = new(now.Hour, now.Minute - now.Minute % 30, 0); - var span = futureTime.AddMinutes(30) - currentTime; + TimeOnly futureTime = new(now.Hour, now.Minute - now.Minute % cleanupCheckMinutes, 0); + var span = futureTime.AddMinutes(cleanupCheckMinutes) - currentTime; _logger.LogInformation("File Cleanup Complete, next run at {date}", now.Add(span)); await Task.Delay(span, ct).ConfigureAwait(false);