mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Add a dedicated error for missing RECORD files (#762)
Related to: https://github.com/astral-sh/puffin/issues/716
This commit is contained in:
parent
2d1d6ac0dd
commit
286145bc7f
3 changed files with 74 additions and 2 deletions
|
@ -80,6 +80,8 @@ pub enum Error {
|
|||
DirectUrlJson(#[from] serde_json::Error),
|
||||
#[error("No .dist-info directory found")]
|
||||
MissingDistInfo,
|
||||
#[error("Cannot uninstall package; RECORD file not found at: {0}")]
|
||||
MissingRecord(PathBuf),
|
||||
#[error("Multiple .dist-info directories found: {0}")]
|
||||
MultipleDistInfo(String),
|
||||
#[error("Invalid wheel size")]
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::collections::BTreeSet;
|
|||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
use fs_err as fs;
|
||||
use fs_err::File;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::{read_record_file, Error};
|
||||
|
@ -16,7 +15,14 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result<Uninstall, Error> {
|
|||
};
|
||||
|
||||
// Read the RECORD file.
|
||||
let mut record_file = File::open(dist_info.join("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()),
|
||||
};
|
||||
let record = read_record_file(&mut record_file)?;
|
||||
|
||||
let mut file_count = 0usize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue