From adafc1dbcf95f75f6bc9059764cabe6288033aff Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Thu, 2 May 2024 15:10:24 +0200 Subject: [PATCH] add access times I guess --- .../Services/CachedFileProvider.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs index 99e3c9c..e23bf11 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/Services/CachedFileProvider.cs @@ -105,14 +105,15 @@ public sealed class CachedFileProvider : IDisposable string coldStorageDir = _configuration.GetValueOrDefault(nameof(StaticFilesServerConfiguration.ColdStorageDirectory), string.Empty); if (string.IsNullOrEmpty(coldStorageDir)) return false; - var coldStorageFilePath = FilePathUtil.GetFilePath(coldStorageDir, hash); - if (!File.Exists(coldStorageFilePath)) return false; + var coldStorageFilePath = FilePathUtil.GetFileInfoForHash(coldStorageDir, hash); + if (coldStorageFilePath == null) return false; try { _logger.LogDebug("Copying {hash} from cold storage: {path}", hash, coldStorageFilePath); var tempFileName = destinationFilePath + ".dl"; - File.Copy(coldStorageFilePath, tempFileName, true); + coldStorageFilePath.LastWriteTimeUtc = DateTime.UtcNow; + File.Copy(coldStorageFilePath.FullName, tempFileName, true); File.Move(tempFileName, destinationFilePath, true); _metrics.IncGauge(MetricsAPI.GaugeFilesTotal); _metrics.IncGauge(MetricsAPI.GaugeFilesTotalSize, new FileInfo(destinationFilePath).Length); @@ -166,6 +167,8 @@ public sealed class CachedFileProvider : IDisposable var fi = FilePathUtil.GetFileInfoForHash(_hotStoragePath, hash); if (fi == null) return null; + fi.LastAccessTimeUtc = DateTime.UtcNow; + _fileStatisticsService.LogFile(hash, fi.Length); return new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Inheritable | FileShare.Read);