static-web-server: handle files from nix store epoch+1
files served from the nix store have time of epoch+1 and static-web-server assumes they're old unchanged files and doesn't send partial updates or refresh the file when it changes. It already has special handling for files with the unix epoch, but the nix store time is epoch+1s; add that special case.
This commit is contained in:
@@ -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 rec {
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user