static-web-server: handle files from nix store epoch+1 (#498890)

This commit is contained in:
Sandro
2026-03-25 20:16:33 +00:00
committed by GitHub
2 changed files with 21 additions and 3 deletions
@@ -0,0 +1,13 @@
diff --git a/src/response.rs b/src/response.rs
index 25da3d3..92d6203 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -42,7 +42,7 @@ pub(crate) fn response_body(
let modified = meta
.modified()
.ok()
- .filter(|&t| t != std::time::UNIX_EPOCH)
+ .filter(|&t| t > (std::time::UNIX_EPOCH + std::time::Duration::from_secs(1)))
.map(LastModified::from);
match conditionals.check(modified) {
@@ -18,9 +18,14 @@ rustPlatform.buildRustPackage (finalAttrs: {
cargoHash = "sha256-rNrGlgUvPezX7RnKhprRjl9DiJ/Crt4phmxnfY9tNXA=";
# Some tests rely on timestamps newer than 18 Nov 1974 00:00:00
preCheck = ''
find docker/public -exec touch -m {} \;
# static-web-server already has special handling for files with modification
# time = unix epoch, but the nix store is unix epoch + 1 second.
patches = [ ./include-unix-time-plus-one.diff ];
# Some tests which implicitly relied on the above behavior now break. Force
# an mtime update to fix.
postUnpack = ''
find . -exec touch -m {} +
'';
# Need to copy in the systemd units for systemd.packages to discover them