Compare commits

...

1 Commits

Author SHA1 Message Date
David Wiesen
1bd7682b37 Skip WindowsApps helper read grants 2026-03-22 21:52:02 -07:00

View File

@@ -287,11 +287,37 @@ fn profile_read_roots(user_profile: &Path) -> Vec<PathBuf> {
.collect()
}
fn is_protected_windowsapps_package_path(path: &Path) -> bool {
for ancestor in path.ancestors() {
let Some(name) = ancestor.file_name() else {
continue;
};
if !name.to_string_lossy().eq_ignore_ascii_case("WindowsApps") {
continue;
}
let Some(parent_name) = ancestor
.parent()
.and_then(Path::file_name)
.map(|value| value.to_string_lossy())
else {
continue;
};
if parent_name.eq_ignore_ascii_case("Program Files")
|| parent_name.eq_ignore_ascii_case("Program Files (x86)")
{
return true;
}
}
false
}
fn gather_helper_read_roots(codex_home: &Path) -> Vec<PathBuf> {
let mut roots = Vec::new();
if let Ok(exe) = std::env::current_exe() {
if let Some(dir) = exe.parent() {
roots.push(dir.to_path_buf());
if !is_protected_windowsapps_package_path(dir) {
roots.push(dir.to_path_buf());
}
}
}
let helper_dir = helper_bin_dir(codex_home);
@@ -723,6 +749,30 @@ mod tests {
assert_eq!(vec![missing_profile], roots);
}
#[test]
fn protected_windowsapps_package_paths_are_excluded_from_helper_roots() {
let tmp = TempDir::new().expect("tempdir");
let store_path = tmp
.path()
.join("Program Files")
.join("WindowsApps")
.join("OpenAI.Codex_26.313.5234.0_x64__2p2nqsd0c76g0")
.join("app")
.join("resources");
fs::create_dir_all(&store_path).expect("create fake store path");
assert!(is_protected_windowsapps_package_path(&store_path));
}
#[test]
fn non_store_paths_are_not_treated_as_windowsapps_packages() {
let tmp = TempDir::new().expect("tempdir");
let regular_path = tmp.path().join("app").join("resources");
fs::create_dir_all(&regular_path).expect("create regular path");
assert!(!is_protected_windowsapps_package_path(&regular_path));
}
#[test]
fn gather_read_roots_includes_helper_bin_dir() {
let tmp = TempDir::new().expect("tempdir");