Skip to content

Commit

Permalink
Fix symlink disabling (#136)
Browse files Browse the repository at this point in the history
* Fix bug where symlink disabling was not respected

* Update lockfile

* Update CHANGELOG

* Update actions
  • Loading branch information
Jake-Shadle authored Aug 21, 2024
1 parent 07cc74a commit 2b22caa
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 59 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- os: ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

# make sure all code has been formatted with rustfmt
Expand All @@ -40,7 +40,7 @@ jobs:
name: Verify compiles
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# Add the actual target we compile for in the test
- run: rustup target add x86_64-pc-windows-msvc
Expand All @@ -66,7 +66,7 @@ jobs:
name: Verify deterministic
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo fetch
- name: cargo test build
Expand All @@ -78,7 +78,7 @@ jobs:
name: Verify CLI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo fetch
- name: cargo test build
Expand All @@ -90,7 +90,7 @@ jobs:
name: cargo-deny
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2

publish-check:
Expand All @@ -106,7 +106,7 @@ jobs:
AR_aarch64_unknown_linux_musl: llvm-ar
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clink-self-contained=yes -Clinker=rust-lld"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
if: endsWith(matrix.target, '-linux-musl')
run: sudo apt-get install -y musl-tools llvm
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: cargo fetch --target ${{ matrix.target }}
- name: Release build
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Fixed
- [PR#136](https://github.com/Jake-Shadle/xwin/pull/136) fixed an issue introduced in [PR#131](https://github.com/Jake-Shadle/xwin/pull/131) where symlink disabling when a case-insensitive file system was detected was...not being respected. At all.

## [0.6.3] - 2024-08-09
### Fixed
- [PR#134](https://github.com/Jake-Shadle/xwin/pull/134) added back onecoreuap headers that were moved from the main SDK header package in recent versions of the SDK. Thanks [@tomager](https://github.com/tomager)!
Expand Down
85 changes: 47 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ crossbeam-channel = "0.5"
# Pretty progress bars
indicatif = "0.17"
# Decoding of MSI installer packages
msi = "0.7"
msi = "0.8"
parking_lot = "0.12"
# brrr
rayon = "1.5"
Expand Down
31 changes: 18 additions & 13 deletions 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 mut splat_config = match &ops {
let splat_config = match &ops {
crate::Ops::Splat(config) => {
let splat_roots = crate::splat::prep_splat(
self.clone(),
Expand Down Expand Up @@ -217,23 +217,28 @@ impl Ctx {

// 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 enable_symlinks = if let Some(root) = splat_config
.as_ref()
.and_then(|(sr, c)| c.enable_symlinks.then_some(&sr.root))
{
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;
let enable_symlinks = if std::fs::read(root.join("big.xwin")).is_ok() {
tracing::warn!("detected splat root '{root}' is on a case-sensitive file system, disabling symlinks");
}
false
} else {
true
};

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

let map = if let Some(map) = splat_config.as_ref().and_then(|(_, sp)| sp.map.as_ref()) {
match std::fs::read_to_string(map) {
Expand Down Expand Up @@ -302,7 +307,7 @@ impl Ctx {
return Ok(());
};

let splat_links = |enable_symlinks: bool| -> anyhow::Result<()> {
let splat_links = || -> anyhow::Result<()> {
if enable_symlinks {
let crt_ft = crt_ft.lock().take();
let atl_ft = atl_ft.lock().take();
Expand All @@ -322,7 +327,7 @@ impl Ctx {

match ops {
crate::Ops::Minimize(config) => {
splat_links(config.enable_symlinks)?;
splat_links()?;
let results = crate::minimize::minimize(self, config, roots, &sdk_version)?;

fn emit(name: &str, num: crate::minimize::FileNumbers) {
Expand Down Expand Up @@ -356,9 +361,9 @@ impl Ctx {
emit("sdk headers", results.sdk_headers);
emit("sdk libs", results.sdk_libs);
}
crate::Ops::Splat(config) => {
crate::Ops::Splat(_config) => {
if map.is_none() {
splat_links(config.enable_symlinks)?;
splat_links()?;
}
}
_ => {}
Expand Down

0 comments on commit 2b22caa

Please sign in to comment.