Skip to content

Commit

Permalink
fix: handle case-insensitive file systems correctly (fixes #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
falko17 committed Dec 27, 2024
1 parent 8532976 commit f3eff17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
Expand Down
17 changes: 13 additions & 4 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down

0 comments on commit f3eff17

Please sign in to comment.