From fb0905ef84ecac7adbbe72a4a9f139b08227952f Mon Sep 17 00:00:00 2001 From: Loporrit <141286461+loporrit@users.noreply.github.com> Date: Fri, 30 Aug 2024 08:32:55 +0000 Subject: [PATCH] check cold storage outside of download task instead --- .../Services/CachedFileProvider.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs index d3508f1..ffb40e9 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs @@ -55,9 +55,6 @@ public sealed class CachedFileProvider : IDisposable { var destinationFilePath = FilePathUtil.GetFilePath(_hotStoragePath, hash); - // first check cold storage - if (TryCopyFromColdStorage(hash, destinationFilePath)) return; - // if cold storage is not configured or file not found or error is present try to download file from remote var downloadUrl = MareFiles.DistributionGetFullPath(_remoteCacheSourceUri, hash); _logger.LogInformation("Did not find {hash}, downloading from {server}", hash, downloadUrl); @@ -134,10 +131,10 @@ public sealed class CachedFileProvider : IDisposable public async Task DownloadFileWhenRequired(string hash) { var fi = FilePathUtil.GetFileInfoForHash(_hotStoragePath, hash); - if (fi == null && IsMainServer) + if (fi == null) { - TryCopyFromColdStorage(hash, FilePathUtil.GetFilePath(_hotStoragePath, hash)); - return; + if (TryCopyFromColdStorage(hash, FilePathUtil.GetFilePath(_hotStoragePath, hash))) + return; } await _downloadSemaphore.WaitAsync().ConfigureAwait(false);