Avoid redundant filesystem probes (#36393)

## What changed

- Load `environments.toml` in one operation, falling back to the default
  environment provider only when the read reports that the file is missing.
- Attempt the default daemon socket connection directly instead of checking the
  socket path first.
- Preserve each file search entry's type from the directory walker, avoiding a
  second metadata lookup when producing matches and correctly classifying
  followed directory symlinks.
- Write atomic-file contents through the existing temporary-file handle rather
  than reopening its path.

## Testing

- Add Unix coverage for classifying a followed directory symlink as a
  directory in file search results.

GitOrigin-RevId: aa6739cac23953ca8b9a3fcb53e43e72c41cfdf9
This commit is contained in:
Charlie Marsh
2026-07-31 21:37:56 +00:00
committed by copyberry
parent dc60dadce6
commit 003ec63bba
4 changed files with 74 additions and 40 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ pub use env::is_wsl;
use codex_utils_absolute_path::AbsolutePathBuf;
use std::collections::HashSet;
use std::io;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use tempfile::NamedTempFile;
@@ -126,8 +127,8 @@ pub fn write_atomically(write_path: &Path, contents: &str) -> io::Result<()> {
)
})?;
std::fs::create_dir_all(parent)?;
let tmp = NamedTempFile::new_in(parent)?;
std::fs::write(tmp.path(), contents)?;
let mut tmp = NamedTempFile::new_in(parent)?;
tmp.write_all(contents.as_bytes())?;
tmp.persist(write_path)?;
Ok(())
}