diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 6b4ab57b..e8457f42 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -1,5 +1,10 @@ # Changes +## [0.1.0] - 2019-05-xx + +* NamedFile last-modified check always fails due to nano-seconds + in file modified date #820 + ## [0.1.0-beta.4] - 2019-05-12 * Update actix-web to beta.4 diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index 41a7cf1f..2298e35a 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -337,7 +337,12 @@ impl Responder for NamedFile { } else if let (Some(ref m), Some(header::IfUnmodifiedSince(ref since))) = (last_modified, req.get_header()) { - m > since + let t1: SystemTime = m.clone().into(); + let t2: SystemTime = since.clone().into(); + match (t1.duration_since(UNIX_EPOCH), t2.duration_since(UNIX_EPOCH)) { + (Ok(t1), Ok(t2)) => t1 > t2, + _ => false, + } } else { false }; @@ -350,7 +355,12 @@ impl Responder for NamedFile { } else if let (Some(ref m), Some(header::IfModifiedSince(ref since))) = (last_modified, req.get_header()) { - m <= since + let t1: SystemTime = m.clone().into(); + let t2: SystemTime = since.clone().into(); + match (t1.duration_since(UNIX_EPOCH), t2.duration_since(UNIX_EPOCH)) { + (Ok(t1), Ok(t2)) => t1 <= t2, + _ => false, + } } else { false };