From 025ea1259dbcefa38ae43699fba02411d9d2cbbd Mon Sep 17 00:00:00 2001 From: Gh4zi Date: Sun, 11 Oct 2026 16:30:50 +0300 Subject: [PATCH] Boot: zone discovery skips cargo output and the artifacts folder When the games root is the build's own `target/play`, discovery walked every file of cargo's output (incremental, deps, build, .fingerprint, examples) and the artifacts folder, several times at boot: the window sat white and "Not Responding" for seconds before the map loaded. Those folders never hold zones, so the walk skips them (retail MW2, MW3 and Black Ops installs have no folders by these names). Co-Authored-By: Claude Opus 5.5 --- crates/asset_transport/src/discover.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/asset_transport/src/discover.rs b/crates/asset_transport/src/discover.rs index c715197..cf35515 100644 --- a/crates/asset_transport/src/discover.rs +++ b/crates/asset_transport/src/discover.rs @@ -250,6 +250,28 @@ fn game_files(root: &Path) -> impl Iterator> { files_under(search_roots(root)) } +/// Folders the game never keeps zones in: cargo's output when the games root is the build's own +/// `target/play` (tens of thousands of files, walked on every discovery), and our own +/// artifacts. +const NOT_GAME_DIRS: [&str; 6] = [ + "incremental", + "deps", + "build", + ".fingerprint", + "examples", + "iw4l-artifacts", +]; + +fn is_not_game_dir(path: &Path) -> bool { + path.file_name() + .and_then(|name| name.to_str()) + .is_some_and(|name| { + NOT_GAME_DIRS + .iter() + .any(|skip| name.eq_ignore_ascii_case(skip)) + }) +} + fn files_under(roots: Vec) -> impl Iterator> { let mut pending: VecDeque<_> = roots.into_iter().map(Ok).collect(); let mut visited = HashSet::new(); @@ -259,6 +281,9 @@ fn files_under(roots: Vec) -> impl Iterator path, Err(error) => return Some(Err(error)), }; + if is_not_game_dir(&path) { + continue; + } let canonical = match std::fs::canonicalize(&path) { Ok(path) => path, Err(error) => {