svenstaro/miniserve

panicked at 'modification time must be after epoch: SystemTimeError(28800s)'

ukuq opened this issue · 6 comments

thread 'actix-rt|system:0|arbiter:0' panicked at 'modification time must be after epoch: SystemTimeError(28800s)', C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\actix-files-0.6.2\src\named.rs:397:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

it's breakdown! maybe because the time of file is invalid,like 0(‎1970‎年‎1‎月‎1‎日,‏‎0:00:00)

Thanks for the report. How can I reproduce this? Can you write a test case that will break it?

Thank you for your reply. This is a bug in named.rs, where the issue arises from potentially negative timestamps during time conversion on the Windows platform, causing an error. I fixed it by adjusting the file's timestamp, and now it's working properly.

Do you think we should fix this in miniserve somehow? Might be nice if it doesn't crash in such cases.

This is a bug within actix-files. Perhaps we could raise an issue with them. On Windows, it's possible for the "mtime" (modification time) to be less than UNIX_EPOCH.

// actix-web/actix-files/src/named.rs:396
let dur = mtime
    .duration_since(UNIX_EPOCH)
    .expect("modification time must be after epoch");

header::EntityTag::new_strong(format!(
    "{:x}:{:x}:{:x}:{:x}",
    ino,
    self.md.len(),
    dur.as_secs(),
    dur.subsec_nanos()
))

Could you perhaps raise an issue upstream about this?

Could you perhaps raise an issue upstream about this?

good idea