[PR #15910] Fix #15907: Handle invalid Win32 FileTime in static files #14461

Open
opened 2026-02-07 07:30:11 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/15910
Author: @ZeusCraft10
Created: 12/31/2025
Status: 🔄 Open

Base: masterHead: fix/issue-15907-static-file-timestamp


📝 Commits (2)

  • 9843f67 Fix infinite metadata pruning loop on rclone/network mounts
  • 117704b Fix #15907: Handle invalid Win32 FileTime in static files

📊 Changes

6 files changed (+275 additions, -15 deletions)

View changed files

📝 CONTRIBUTORS.md (+1 -0)
Jellyfin.Server/Infrastructure/SafeTimestampFileInfo.cs (+67 -0)
Jellyfin.Server/Infrastructure/SafeTimestampFileProvider.cs (+57 -0)
📝 Jellyfin.Server/Startup.cs (+3 -2)
📝 MediaBrowser.Providers/Manager/MetadataService.cs (+19 -13)
tests/Jellyfin.Server.Tests/SafeTimestampFileInfoTests.cs (+128 -0)

📄 Description

Summary

Fixes #15907 - Web UI fails to load with \ArgumentOutOfRangeException: Not a valid Win32 FileTime.

Root Cause

Files in Docker containers can have timestamps before January 1, 1601 (the Win32 epoch), causing \DateTime.ToFileTimeUtc()\ to throw when the StaticFileMiddleware tries to generate \ETag/\Last-Modified\ headers.

Solution

Implemented a defense-in-depth wrapper pattern:

  • SafeTimestampFileProvider: Wraps \PhysicalFileProvider, returns safe file info
  • SafeTimestampFileInfo: Wraps \IFileInfo, clamps invalid timestamps to Unix epoch (1970-01-01)

Changes

File Action
\Jellyfin.Server/Infrastructure/SafeTimestampFileInfo.cs\ NEW
\Jellyfin.Server/Infrastructure/SafeTimestampFileProvider.cs\ NEW
\Jellyfin.Server/Startup.cs\ Modified to use SafeTimestampFileProvider
\ ests/Jellyfin.Server.Tests/SafeTimestampFileInfoTests.cs\ NEW - 7 unit tests

Testing

  • Build passes (0 errors, 0 warnings)
  • All unit tests pass

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/15910 **Author:** [@ZeusCraft10](https://github.com/ZeusCraft10) **Created:** 12/31/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/issue-15907-static-file-timestamp` --- ### 📝 Commits (2) - [`9843f67`](https://github.com/jellyfin/jellyfin/commit/9843f6783c5776c3ca036badcb85a3ffb49b7d62) Fix infinite metadata pruning loop on rclone/network mounts - [`117704b`](https://github.com/jellyfin/jellyfin/commit/117704b86c7cf830db0bee0324e770db1620a6e3) Fix #15907: Handle invalid Win32 FileTime in static files ### 📊 Changes **6 files changed** (+275 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CONTRIBUTORS.md` (+1 -0) ➕ `Jellyfin.Server/Infrastructure/SafeTimestampFileInfo.cs` (+67 -0) ➕ `Jellyfin.Server/Infrastructure/SafeTimestampFileProvider.cs` (+57 -0) 📝 `Jellyfin.Server/Startup.cs` (+3 -2) 📝 `MediaBrowser.Providers/Manager/MetadataService.cs` (+19 -13) ➕ `tests/Jellyfin.Server.Tests/SafeTimestampFileInfoTests.cs` (+128 -0) </details> ### 📄 Description ## Summary Fixes #15907 - Web UI fails to load with \ArgumentOutOfRangeException: Not a valid Win32 FileTime\. ## Root Cause Files in Docker containers can have timestamps before January 1, 1601 (the Win32 epoch), causing \DateTime.ToFileTimeUtc()\ to throw when the StaticFileMiddleware tries to generate \ETag\/\Last-Modified\ headers. ## Solution Implemented a defense-in-depth wrapper pattern: - **SafeTimestampFileProvider**: Wraps \PhysicalFileProvider\, returns safe file info - **SafeTimestampFileInfo**: Wraps \IFileInfo\, clamps invalid timestamps to Unix epoch (1970-01-01) ## Changes | File | Action | |------|--------| | \Jellyfin.Server/Infrastructure/SafeTimestampFileInfo.cs\ | NEW | | \Jellyfin.Server/Infrastructure/SafeTimestampFileProvider.cs\ | NEW | | \Jellyfin.Server/Startup.cs\ | Modified to use SafeTimestampFileProvider | | \ ests/Jellyfin.Server.Tests/SafeTimestampFileInfoTests.cs\ | NEW - 7 unit tests | ## Testing - [x] Build passes (0 errors, 0 warnings) - [x] All unit tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 07:30:11 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#14461