Skip to content

Commit

Permalink
#280: Round up mtimes for zip archives if before 1980
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 2, 2023
1 parent 1af8e5e commit 12d504e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* Added:
* When a path or URL fails to open, additional information is now logged.
* Fixed:
* When storing file modified times in zip archives,
if the year is too old for zip to support (i.e., before 1980),
Ludusavi will now round up to the earliest support date (1980-01-01).

## v0.21.0 (2023-08-22)

Expand Down
8 changes: 8 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ impl StrictPath {
use chrono::{Datelike, Timelike};

let mtime: chrono::DateTime<chrono::Utc> = self.get_mtime()?.into();

// Zip doesn't support years before 1980,
// and this is probably just a default Unix timestamp anyway,
// so we round up.
if mtime.year() < 1980 {
return Ok(zip::DateTime::default());
}

let converted = zip::DateTime::from_date_and_time(
mtime.year() as u16,
mtime.month() as u8,
Expand Down

0 comments on commit 12d504e

Please sign in to comment.