From 1c1d08c3b2f235c90691bc80081a0f41886269c4 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 2 Jul 2024 10:35:05 +0200 Subject: [PATCH] Detect case insensitive splat directories (#131) * Detect case insensitive splat directories * Update CHANGELOG --- CHANGELOG.md | 3 +++ src/ctx.rs | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 919ae15..6b435bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Fixed +- [PR#131](https://github.com/Jake-Shadle/xwin/pull/131) resolved [#130](https://github.com/Jake-Shadle/xwin/issues/130) by adding detection of case-insensitive file systems, which then disables symlink creation since it is not needed, and breaks. + ## [0.6.1] - 2024-06-30 ### Fixed - [PR#129](https://github.com/Jake-Shadle/xwin/pull/129) fixed [#128](https://github.com/Jake-Shadle/xwin/issues/128) by adding the additional `onecoreuap` MSI package that contains headers that were previously (before SDK 10.0.26100) part of other MSI packages. Thanks [@bigfoodK](https://github.com/bigfoodK)! diff --git a/src/ctx.rs b/src/ctx.rs index 1996b3e..16dcecc 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -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(), @@ -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(