diff --git a/abstio/src/abst_data.rs b/abstio/src/abst_data.rs index 5012c796e5..f5607050ef 100644 --- a/abstio/src/abst_data.rs +++ b/abstio/src/abst_data.rs @@ -16,10 +16,11 @@ pub struct Manifest { pub struct Entry { /// md5sum of the file pub checksum: String, - /// Uncompressed size in bytes - pub uncompressed_size_bytes: usize, + /// Uncompressed size in bytes. Because we have some massive files more than 2^32 bytes + /// described by this, explicitly use u64 instead of usize, so wasm doesn't break. + pub uncompressed_size_bytes: u64, /// Compressed size in bytes - pub compressed_size_bytes: usize, + pub compressed_size_bytes: u64, } impl Manifest { diff --git a/map_gui/src/tools/updater.rs b/map_gui/src/tools/updater.rs index bd32ee78ce..b5972a5979 100644 --- a/map_gui/src/tools/updater.rs +++ b/map_gui/src/tools/updater.rs @@ -107,7 +107,7 @@ impl State for Picker { } // For each city, how many total bytes do the runtime files cost to download? -fn size_per_city(manifest: &Manifest) -> BTreeMap { +fn size_per_city(manifest: &Manifest) -> BTreeMap { let mut per_city = BTreeMap::new(); for (path, entry) in &manifest.entries { let parts = path.split("/").collect::>(); @@ -122,7 +122,7 @@ fn size_per_city(manifest: &Manifest) -> BTreeMap { per_city } -fn prettyprint_bytes(bytes: usize) -> String { +fn prettyprint_bytes(bytes: u64) -> String { if bytes < 1024 { return format!("{} bytes", bytes); } @@ -220,13 +220,13 @@ pub fn sync_missing_files(timer: &mut Timer) -> Vec { } // Bytes downloaded if succesful -fn download(url: &str, local_path: String) -> Result { +fn download(url: &str, local_path: String) -> Result { let mut resp = reqwest::blocking::get(url)?; if !resp.status().is_success() { bail!("bad status: {:?}", resp.status()); } let mut buffer: Vec = Vec::new(); - let bytes = resp.copy_to(&mut buffer)? as usize; + let bytes = resp.copy_to(&mut buffer)?; info!("Decompressing {} ({})", url, prettyprint_bytes(bytes)); let mut decoder = flate2::read::GzDecoder::new(&buffer[..]); diff --git a/updater/src/main.rs b/updater/src/main.rs index 4a73c6fa01..cf50bf4e63 100644 --- a/updater/src/main.rs +++ b/updater/src/main.rs @@ -156,7 +156,7 @@ fn upload(version: String) { // generate_manifest. entry.compressed_size_bytes = std::fs::metadata(&remote_path) .expect(&format!("Compressed {} not there?", remote_path)) - .len() as usize; + .len(); (path, entry) }, ) { @@ -254,7 +254,7 @@ fn generate_manifest() -> Manifest { } /// Returns (checksum, uncompressed_size_bytes) -fn md5sum(path: &str) -> (String, usize) { +fn md5sum(path: &str) -> (String, u64) { // since these files can be very large, computes the md5 hash in chunks let mut file = File::open(path).unwrap(); let mut buffer = [0 as u8; MD5_BUF_READ_SIZE]; @@ -267,7 +267,10 @@ fn md5sum(path: &str) -> (String, usize) { uncompressed_size_bytes += n; context.consume(&buffer[..n]); } - (format!("{:x}", context.compute()), uncompressed_size_bytes) + ( + format!("{:x}", context.compute()), + uncompressed_size_bytes as u64, + ) } fn rm(path: &str) {