mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-03 13:14:41 +00:00
Close RECORD after reading entries during uninstall (#2259)
## Summary It turns out that by keeping the `RECORD` file open, older versions of Windows mark it for deletion, but don't allow it to be deleted until it's closed. As such, we end up leaving the `.dist-info` directory around, since it appears non-empty; but once the program terminates, we _do_ delete `RECORD`, leaving it empty. This then creates the impression that a package exists where it does not. Closes https://github.com/astral-sh/uv/issues/2074.
This commit is contained in:
parent
b061db094d
commit
59f4639863
1 changed files with 10 additions and 8 deletions
|
|
@ -16,15 +16,17 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result<Uninstall, Error> {
|
|||
};
|
||||
|
||||
// Read the RECORD file.
|
||||
let record_path = dist_info.join("RECORD");
|
||||
let mut record_file = match fs::File::open(&record_path) {
|
||||
Ok(record_file) => record_file,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||
return Err(Error::MissingRecord(record_path));
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
let record = {
|
||||
let record_path = dist_info.join("RECORD");
|
||||
let mut record_file = match fs::File::open(&record_path) {
|
||||
Ok(record_file) => record_file,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||
return Err(Error::MissingRecord(record_path));
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
read_record_file(&mut record_file)?
|
||||
};
|
||||
let record = read_record_file(&mut record_file)?;
|
||||
|
||||
let mut file_count = 0usize;
|
||||
let mut dir_count = 0usize;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue