mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-25 21:37:51 +00:00
Remove unused Result (#849)
Remove some dead code, seems to be a refactoring oversight
This commit is contained in:
parent
643e5e4a49
commit
ee6d809b60
3 changed files with 9 additions and 46 deletions
|
|
@ -141,23 +141,16 @@ pub struct CachedWheel {
|
||||||
|
|
||||||
impl CachedWheel {
|
impl CachedWheel {
|
||||||
/// Try to parse a distribution from a cached directory name (like `typing-extensions-4.8.0-py3-none-any`).
|
/// Try to parse a distribution from a cached directory name (like `typing-extensions-4.8.0-py3-none-any`).
|
||||||
pub fn from_path(path: &Path) -> Result<Option<Self>> {
|
pub fn from_path(path: &Path) -> Option<Self> {
|
||||||
let Some(file_name) = path.file_name() else {
|
let filename = path.file_name()?.to_str()?;
|
||||||
return Ok(None);
|
let filename = WheelFilename::from_stem(filename).ok()?;
|
||||||
};
|
|
||||||
let Some(file_name) = file_name.to_str() else {
|
|
||||||
return Ok(None);
|
|
||||||
};
|
|
||||||
let Ok(filename) = WheelFilename::from_stem(file_name) else {
|
|
||||||
return Ok(None);
|
|
||||||
};
|
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
return Ok(None);
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = path.to_path_buf();
|
let path = path.to_path_buf();
|
||||||
|
|
||||||
Ok(Some(Self { filename, path }))
|
Some(Self { filename, path })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a [`CachedWheel`] into a [`CachedRegistryDist`].
|
/// Convert a [`CachedWheel`] into a [`CachedRegistryDist`].
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
use fs_err as fs;
|
|
||||||
use tracing::warn;
|
|
||||||
|
|
||||||
use distribution_types::CachedWheel;
|
use distribution_types::CachedWheel;
|
||||||
use platform_tags::Tags;
|
use platform_tags::Tags;
|
||||||
use puffin_cache::CacheShard;
|
use puffin_cache::CacheShard;
|
||||||
|
|
@ -31,8 +28,8 @@ impl BuiltWheelIndex {
|
||||||
|
|
||||||
for subdir in directories(&**shard) {
|
for subdir in directories(&**shard) {
|
||||||
match CachedWheel::from_path(&subdir) {
|
match CachedWheel::from_path(&subdir) {
|
||||||
Ok(None) => {}
|
None => {}
|
||||||
Ok(Some(dist_info)) => {
|
Some(dist_info) => {
|
||||||
// Pick the wheel with the highest priority
|
// Pick the wheel with the highest priority
|
||||||
let compatibility = dist_info.filename.compatibility(tags);
|
let compatibility = dist_info.filename.compatibility(tags);
|
||||||
|
|
||||||
|
|
@ -56,18 +53,6 @@ impl BuiltWheelIndex {
|
||||||
candidate = Some(dist_info);
|
candidate = Some(dist_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
warn!(
|
|
||||||
"Invalid cache entry at {}, removing. {err}",
|
|
||||||
subdir.display()
|
|
||||||
);
|
|
||||||
if let Err(err) = fs::remove_dir_all(&subdir) {
|
|
||||||
warn!(
|
|
||||||
"Failed to remove invalid cache entry at {}: {err}",
|
|
||||||
subdir.display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ use std::collections::hash_map::Entry;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use fs_err as fs;
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use tracing::warn;
|
|
||||||
|
|
||||||
use distribution_types::{CachedRegistryDist, CachedWheel, IndexUrls};
|
use distribution_types::{CachedRegistryDist, CachedWheel, IndexUrls};
|
||||||
use pep440_rs::Version;
|
use pep440_rs::Version;
|
||||||
|
|
@ -110,8 +108,8 @@ impl<'a> RegistryWheelIndex<'a> {
|
||||||
) {
|
) {
|
||||||
for wheel_dir in directories(path.as_ref()) {
|
for wheel_dir in directories(path.as_ref()) {
|
||||||
match CachedWheel::from_path(&wheel_dir) {
|
match CachedWheel::from_path(&wheel_dir) {
|
||||||
Ok(None) => {}
|
None => {}
|
||||||
Ok(Some(dist_info)) => {
|
Some(dist_info) => {
|
||||||
let dist_info = dist_info.into_registry_dist();
|
let dist_info = dist_info.into_registry_dist();
|
||||||
|
|
||||||
// Pick the wheel with the highest priority
|
// Pick the wheel with the highest priority
|
||||||
|
|
@ -125,19 +123,6 @@ impl<'a> RegistryWheelIndex<'a> {
|
||||||
versions.insert(dist_info.filename.version.clone(), dist_info);
|
versions.insert(dist_info.filename.version.clone(), dist_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
warn!(
|
|
||||||
"Invalid cache entry at {}, removing. {err}",
|
|
||||||
wheel_dir.display()
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Err(err) = fs::remove_dir_all(&wheel_dir) {
|
|
||||||
warn!(
|
|
||||||
"Failed to remove invalid cache entry at {}: {err}",
|
|
||||||
wheel_dir.display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue