From f3eff17490f93c8482fd07dd8704d938dff38309 Mon Sep 17 00:00:00 2001 From: Falko Galperin Date: Fri, 27 Dec 2024 00:47:31 +0100 Subject: [PATCH] fix: handle case-insensitive file systems correctly (fixes #5) --- Cargo.toml | 2 +- src/download.rs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b482cb2..f2964ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "aaoffline" description = "Downloads cases from Ace Attorney Online to be playable offline" repository = "https://github.com/falko17/aaoffline" -version = "1.1.0" +version = "1.1.1" edition = "2021" license = "MIT" authors = ["Falko Galperin "] diff --git a/src/download.rs b/src/download.rs index a5c1536..19c30c1 100644 --- a/src/download.rs +++ b/src/download.rs @@ -180,10 +180,19 @@ impl AssetCollector { } /// Checks whether a [path] exists already in the collected downloads. - fn path_exists(&self, path: &PathBuf) -> bool { - self.collected - .iter() - .any(|x| x.as_ref().ok().map_or(false, |x| x.path == *path)) + fn path_exists(&self, path: &Path) -> bool { + // Need to use a lower-case comparison here, otherwise we'll run into problems on Windows + // (where the file system is usually case-insensitive). + let lower_path = path + .to_str() + .expect("Invalid path encountered") + .to_lowercase(); + self.collected.iter().any(|x| { + x.as_ref() + .ok() + .and_then(|y| y.path.to_str()) + .map_or(false, |y| y.to_lowercase() == lower_path) + }) } /// Creates a new unique path for the given [url] and [path].