diff --git a/allstarr/Controllers/JellyfinController.cs b/allstarr/Controllers/JellyfinController.cs index 840bf11..1b0f7ce 100644 --- a/allstarr/Controllers/JellyfinController.cs +++ b/allstarr/Controllers/JellyfinController.cs @@ -811,6 +811,16 @@ public class JellyfinController : ControllerBase if (localPath != null && System.IO.File.Exists(localPath)) { + // Update last access time for cache cleanup + try + { + System.IO.File.SetLastAccessTimeUtc(localPath, DateTime.UtcNow); + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to update last access time for {Path}", localPath); + } + var stream = System.IO.File.OpenRead(localPath); return File(stream, GetContentType(localPath), enableRangeProcessing: true); } diff --git a/allstarr/Controllers/SubSonicController.cs b/allstarr/Controllers/SubSonicController.cs index 97183d4..19cf510 100644 --- a/allstarr/Controllers/SubSonicController.cs +++ b/allstarr/Controllers/SubSonicController.cs @@ -64,7 +64,7 @@ public class SubsonicController : ControllerBase { return await _requestParser.ExtractAllParametersAsync(Request); } - + /// /// Merges local and external search results. /// @@ -142,6 +142,16 @@ public class SubsonicController : ControllerBase if (localPath != null && System.IO.File.Exists(localPath)) { + // Update last access time for cache cleanup + try + { + System.IO.File.SetLastAccessTimeUtc(localPath, DateTime.UtcNow); + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to update last access time for {Path}", localPath); + } + var stream = System.IO.File.OpenRead(localPath); return File(stream, GetContentType(localPath), enableRangeProcessing: true); }