Skip to content

Commit

Permalink
Merge pull request #26 from LaylConway/master
Browse files Browse the repository at this point in the history
Fix gzip decode crash on wasm32
  • Loading branch information
sile authored Apr 14, 2019
2 parents 4a53100 + ab7cfa8 commit c8b92a7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gzip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ impl HeaderBuilder {
/// assert_eq!(header.comment(), None);
/// ```
pub fn new() -> Self {
// wasm-unknown-unknown does not implement the time module
#[cfg(not(target_arch = "wasm32"))]
let modification_time = time::UNIX_EPOCH
.elapsed()
.map(|d| d.as_secs() as u32)
.unwrap_or(0);
#[cfg(target_arch = "wasm32")]
let modification_time = 0;

let header = Header {
modification_time,
compression_level: CompressionLevel::Unknown,
Expand Down

0 comments on commit c8b92a7

Please sign in to comment.