Skip to content

Commit

Permalink
Detect case insensitive splat directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Jul 2, 2024
1 parent d57f099 commit ab66333
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Ctx {
let crt_ft = parking_lot::Mutex::new(None);
let atl_ft = parking_lot::Mutex::new(None);

let splat_config = match &ops {
let mut splat_config = match &ops {
crate::Ops::Splat(config) => {
let splat_roots = crate::splat::prep_splat(
self.clone(),
Expand Down Expand Up @@ -215,6 +215,26 @@ impl Ctx {
_ => None,
};

// Detect if the output root directory is case sensitive or not,
// if it's not, disable symlinks as they won't work
if let Some((root, enable_symlinks)) = splat_config.as_mut().and_then(|(sr, c)| {
c.enable_symlinks
.then_some((&sr.root, &mut c.enable_symlinks))
}) {
let test_path = root.join("BIG.xwin");
std::fs::write(&test_path, "").with_context(|| {
format!("failed to write case-sensitivity test file {test_path}")
})?;

if std::fs::read(root.join("big.xwin")).is_ok() {
*enable_symlinks = false;
tracing::warn!("detected splat root '{root}' is on a case-sensitive file system, disabling symlinks");
}

// Will be ugly but won't harm anything if file is left
let _ = std::fs::remove_file(test_path);
}

let map = if let Some(map) = splat_config.as_ref().and_then(|(_, sp)| sp.map.as_ref()) {
match std::fs::read_to_string(map) {
Ok(m) => Some(
Expand Down

0 comments on commit ab66333

Please sign in to comment.