Fix: Update last access time for cached files to enable proper cleanup

This commit is contained in:
2026-01-30 00:41:17 -05:00
parent 4afd769602
commit 80424a867d
2 changed files with 21 additions and 1 deletions

View File

@@ -811,6 +811,16 @@ public class JellyfinController : ControllerBase
if (localPath != null && System.IO.File.Exists(localPath)) 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); var stream = System.IO.File.OpenRead(localPath);
return File(stream, GetContentType(localPath), enableRangeProcessing: true); return File(stream, GetContentType(localPath), enableRangeProcessing: true);
} }

View File

@@ -142,6 +142,16 @@ public class SubsonicController : ControllerBase
if (localPath != null && System.IO.File.Exists(localPath)) 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); var stream = System.IO.File.OpenRead(localPath);
return File(stream, GetContentType(localPath), enableRangeProcessing: true); return File(stream, GetContentType(localPath), enableRangeProcessing: true);
} }