actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

Actix Files does not serve files with a modification date before UNIX epoch

Open marknijboer opened this issue 2 years ago • 2 comments

Expected Behavior

I was working with archive video footage that has its modification date set to the date it was shot. In my case a video from 1964. I expected this video to be served without any issues.

Current Behavior

A panic with this message:

thread 'actix-rt|system:0|arbiter:0' panicked at 'modification time must be after epoch: SystemTimeError(189347400s)', /cargo/registry/src/github.com-1ecc6299db9ec823/actix-files-0.6.0/src/named.rs:360:18

Steps to Reproduce (for bugs)

  1. Set the modification date of the file to a date before 1970. E.g.:
# Sets the file's modification date to 12th of February, 1964.
touch -t 196402121230 <file>
  1. Try to access that file through Actix Files as a named file.

Your Environment

actix-web = { version = "4.0", features = ["rustls"] }
actix-rt = "2.7"
actix-cors = "0.6"
actix-files = "0.6"
rustc 1.60.0 (7737e0b5c 2022-04-04)

Running in production on Ubuntu Linux (5.4.0-107-generic).

marknijboer avatar Apr 26 '22 23:04 marknijboer

I have been testing with a change (https://github.com/marknijboer/actix-web/commit/19608e743053b79ad40c2fde7a27eedff719beb5) that allows pre-epoch modification times for NamedFiles. This makes the generation of etags possible, but unfortunately a new issue pops up in an external crate httpdate:

panicked at 'all times should be after the epoch: SystemTimeError(189347400s)', /registry/src/github.com-1ecc6299db9ec823/httpdate-1.0.2/src/date.rs:51:14

This error occurs in fn last_modified(&self) -> Option<header::HttpDate>, where a SystemTime is being converted to a HttpDate that does not support pre-epoch times :-(

marknijboer avatar Apr 30 '22 21:04 marknijboer

I have encountered this issue as well https://github.com/svenstaro/miniserve/issues/1288

ukuq avatar Dec 11 '23 03:12 ukuq