diff --git a/src/package.rs b/src/package.rs index 23d0620..aefd7ff 100644 --- a/src/package.rs +++ b/src/package.rs @@ -103,7 +103,8 @@ fn zip_folder(path: &Path, output: &Path) { // Setup zip let mut zip_file = ZipWriter::new(fs::File::create(output).unwrap()); - let zip_options = FileOptions::<()>::default().compression_method(zip::CompressionMethod::Deflated); + let zip_options = + FileOptions::<()>::default().compression_method(zip::CompressionMethod::Deflated); // Iterate files in target path for item in walkdir::WalkDir::new(path) { @@ -142,7 +143,8 @@ fn zip_folder(path: &Path, output: &Path) { pub fn get_working_dir(id: &String) -> PathBuf { let working_dir = dirs::cache_dir().unwrap().join("geode_pkg").join(id); - fs::remove_dir_all(&working_dir).unwrap_or(()); + // why would u do that :( + // fs::remove_dir_all(&working_dir).unwrap_or(()); fs::create_dir_all(&working_dir).unwrap_or(()); working_dir } diff --git a/src/util/bmfont.rs b/src/util/bmfont.rs index 1b51942..33e4915 100644 --- a/src/util/bmfont.rs +++ b/src/util/bmfont.rs @@ -317,12 +317,12 @@ fn extract_from_cache( working_dir: &Path, cache_bundle: &mut CacheBundle, shut_up: bool, -) { +) -> bool { let path_name = path.to_str().unwrap(); if !shut_up { info!("Extracting '{}' from cache", path_name); } - cache_bundle.try_extract_cached_into( + return cache_bundle.try_extract_cached_into( path_name, &working_dir.join(path.file_name().unwrap().to_str().unwrap()), ); @@ -344,21 +344,26 @@ pub fn get_font_bundles( if let Some(cache_bundle) = cache { // Cache found if let Some(p) = cache_bundle.cache.fetch_font_bundles(font) { - if !shut_up { - info!("Using cached files"); - } let bundles = FontBundles::new(p.to_path_buf()); // Extract all files - extract_from_cache(&bundles.sd.png, working_dir, cache_bundle, shut_up); - extract_from_cache(&bundles.sd.fnt, working_dir, cache_bundle, shut_up); - extract_from_cache(&bundles.hd.png, working_dir, cache_bundle, shut_up); - extract_from_cache(&bundles.hd.fnt, working_dir, cache_bundle, shut_up); - extract_from_cache(&bundles.uhd.png, working_dir, cache_bundle, shut_up); - extract_from_cache(&bundles.uhd.fnt, working_dir, cache_bundle, shut_up); - - done!("Fetched {} from cache", font.name.bright_yellow()); - return bundles; + let success = extract_from_cache(&bundles.sd.png, working_dir, cache_bundle, shut_up) + && extract_from_cache(&bundles.sd.fnt, working_dir, cache_bundle, shut_up) + && extract_from_cache(&bundles.hd.png, working_dir, cache_bundle, shut_up) + && extract_from_cache(&bundles.hd.fnt, working_dir, cache_bundle, shut_up) + && extract_from_cache(&bundles.uhd.png, working_dir, cache_bundle, shut_up) + && extract_from_cache(&bundles.uhd.fnt, working_dir, cache_bundle, shut_up); + + if success { + if !shut_up { + info!("Using cached files"); + } + + done!("Fetched {} from cache", font.name.bright_yellow()); + return bundles; + } else { + info!("Failed to extract cached files"); + } } } diff --git a/src/util/cache.rs b/src/util/cache.rs index b991b7c..7288176 100644 --- a/src/util/cache.rs +++ b/src/util/cache.rs @@ -24,7 +24,11 @@ impl CacheBundle { pub fn try_extract_cached_into(&mut self, name: &str, output: &PathBuf) -> bool { match &mut self.src { CacheBundleSource::Archive(archive) => { - let Ok(mut cached_file) = archive.by_name(name) else { + // zip doesn't really know what a folder is, so it just sees + // backslashes as a different filename. so ofc it breaks on windows + // and we have to do this + let name = name.replace('\\', "/"); + let Ok(mut cached_file) = archive.by_name(&name) else { return false; };