Don't fail on creation of sdist-vX/.git if it already exists (#17825)

Step 1 of N for readonly cache support. Moves the error message for LLM
sandboxes from `sdist-vX/.git` to:

```
error: Could not acquire lock
    Caused by: Could not create temporary file
    Caused by: Read-only file system (os error 30  at path "/home/konsti/.cache/uv/.tmpfvc4gV"
```
This commit is contained in:
konsti
2026-02-06 14:46:03 +01:00
committed by GitHub
parent 05055822b2
commit 0dbeb4cd3d
+17 -4
View File
@@ -445,10 +445,23 @@ impl Cache {
// We have to put this below the gitignore. Otherwise, if the build backend uses the rust
// ignore crate it will walk up to the top level .gitignore and ignore its python source
// files.
fs_err::OpenOptions::new().create(true).write(true).open(
root.join(CacheBucket::SourceDistributions.to_str())
.join(".git"),
)?;
let phony_git = root
.join(CacheBucket::SourceDistributions.to_str())
.join(".git");
match fs_err::OpenOptions::new()
.create(true)
.write(true)
.open(&phony_git)
{
Ok(_) => {}
// Handle read-only caches including sandboxed environments.
Err(err) if err.kind() == io::ErrorKind::ReadOnlyFilesystem => {
if !phony_git.exists() {
return Err(err);
}
}
Err(err) => return Err(err),
}
Ok(())
}