From 80424a867df5e1ee9c5a34537f4ef4ec2c672d1d Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Fri, 30 Jan 2026 00:41:17 -0500 Subject: [PATCH] Fix: Update last access time for cached files to enable proper cleanup --- allstarr/Controllers/JellyfinController.cs | 10 ++++++++++ allstarr/Controllers/SubSonicController.cs | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) 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); }