Fix huge_seattle data pack issue introduced a few commits ago

This commit is contained in:
Dustin Carlino 2021-04-20 11:35:30 -07:00
parent ee78644089
commit a2f08dcc52
2 changed files with 13 additions and 15 deletions

View File

@ -54,16 +54,16 @@ impl Manifest {
} }
let parts = path.split("/").collect::<Vec<_>>(); let parts = path.split("/").collect::<Vec<_>>();
let mut city = format!("{}/{}", parts[2], parts[3]); let mut data_pack = format!("{}/{}", parts[2], parts[3]);
if Manifest::is_file_part_of_huge_seattle(path) { if Manifest::is_file_part_of_huge_seattle(path) {
city = "us/huge_seattle".to_string(); data_pack = "us/huge_seattle".to_string();
} }
if parts[1] == "input" { if parts[1] == "input" {
if data_packs.input.contains(&city) { if data_packs.input.contains(&data_pack) {
continue; continue;
} }
} else if parts[1] == "system" { } else if parts[1] == "system" {
if data_packs.runtime.contains(&city) { if data_packs.runtime.contains(&data_pack) {
continue; continue;
} }
} else { } else {
@ -82,7 +82,10 @@ impl Manifest {
/// "us/huge_seattle" pack has the rest. This returns true for files belonging to /// "us/huge_seattle" pack has the rest. This returns true for files belonging to
/// "us/huge_seattle". /// "us/huge_seattle".
pub fn is_file_part_of_huge_seattle(path: &str) -> bool { pub fn is_file_part_of_huge_seattle(path: &str) -> bool {
let path = path.strip_prefix(&crate::path("")).unwrap_or(path); let path = path
.strip_prefix(&crate::path(""))
.or_else(|| path.strip_prefix("data/"))
.unwrap_or_else(|| path);
let name = if let Some(x) = path.strip_prefix("system/us/seattle/maps/") { let name = if let Some(x) = path.strip_prefix("system/us/seattle/maps/") {
x.strip_suffix(".bin").unwrap() x.strip_suffix(".bin").unwrap()
} else if let Some(x) = path.strip_prefix("system/us/seattle/scenarios/") { } else if let Some(x) = path.strip_prefix("system/us/seattle/scenarios/") {
@ -110,11 +113,7 @@ impl Manifest {
{ {
return None; return None;
} }
if Manifest::is_file_part_of_huge_seattle(path) { return Some(CityName::new(parts[2], parts[3]));
return Some(CityName::new("us", "huge_seattle"));
} else {
return Some(CityName::new(parts[2], parts[3]));
}
} }
None None
} }

View File

@ -3,7 +3,7 @@ use std::fs::File;
use futures_channel::mpsc; use futures_channel::mpsc;
use abstio::{CityName, DataPacks, Manifest, MapName}; use abstio::{DataPacks, Manifest, MapName};
use widgetry::{EventCtx, Key, Transition}; use widgetry::{EventCtx, Key, Transition};
use crate::load::FutureLoader; use crate::load::FutureLoader;
@ -16,13 +16,12 @@ const NEXT_RELEASE: &str = "0.2.41";
// For each city, how many total bytes do the runtime files cost to download? // For each city, how many total bytes do the runtime files cost to download?
/// How many bytes to download for a city? /// How many bytes to download for a city?
fn size_of_city(city: &CityName) -> u64 { fn size_of_city(map: &MapName) -> u64 {
let mut data_packs = DataPacks { let mut data_packs = DataPacks {
runtime: BTreeSet::new(), runtime: BTreeSet::new(),
input: BTreeSet::new(), input: BTreeSet::new(),
}; };
// TODO huge_seattle breaks here... data_packs.runtime.insert(map.to_data_pack_name());
data_packs.runtime.insert(city.to_path());
let mut manifest = Manifest::load().filter(data_packs); let mut manifest = Manifest::load().filter(data_packs);
// Don't download files that already exist // Don't download files that already exist
abstutil::retain_btreemap(&mut manifest.entries, |path, _| { abstutil::retain_btreemap(&mut manifest.entries, |path, _| {
@ -58,7 +57,7 @@ pub fn prompt_to_download_missing_data<A: AppLike + 'static>(
ctx, ctx,
format!( format!(
"Missing data. Download {} for {}?", "Missing data. Download {} for {}?",
prettyprint_bytes(size_of_city(&map_name.city)), prettyprint_bytes(size_of_city(&map_name)),
map_name.city.describe() map_name.city.describe()
), ),
vec![ vec![