Remove unused Result (#849)

Remove some dead code, seems to be a refactoring oversight
This commit is contained in:
konsti 2024-01-09 17:35:10 +01:00 committed by GitHub
parent 643e5e4a49
commit ee6d809b60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 46 deletions

View file

@ -141,23 +141,16 @@ pub struct CachedWheel {
impl CachedWheel {
/// 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>> {
let Some(file_name) = path.file_name() else {
return Ok(None);
};
let Some(file_name) = file_name.to_str() else {
return Ok(None);
};
let Ok(filename) = WheelFilename::from_stem(file_name) else {
return Ok(None);
};
pub fn from_path(path: &Path) -> Option<Self> {
let filename = path.file_name()?.to_str()?;
let filename = WheelFilename::from_stem(filename).ok()?;
if path.is_file() {
return Ok(None);
return None;
}
let path = path.to_path_buf();
Ok(Some(Self { filename, path }))
Some(Self { filename, path })
}
/// Convert a [`CachedWheel`] into a [`CachedRegistryDist`].

View file

@ -1,6 +1,3 @@
use fs_err as fs;
use tracing::warn;
use distribution_types::CachedWheel;
use platform_tags::Tags;
use puffin_cache::CacheShard;
@ -31,8 +28,8 @@ impl BuiltWheelIndex {
for subdir in directories(&**shard) {
match CachedWheel::from_path(&subdir) {
Ok(None) => {}
Ok(Some(dist_info)) => {
None => {}
Some(dist_info) => {
// Pick the wheel with the highest priority
let compatibility = dist_info.filename.compatibility(tags);
@ -56,18 +53,6 @@ impl BuiltWheelIndex {
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()
);
}
}
}
}

View file

@ -2,9 +2,7 @@ use std::collections::hash_map::Entry;
use std::collections::BTreeMap;
use std::path::Path;
use fs_err as fs;
use rustc_hash::FxHashMap;
use tracing::warn;
use distribution_types::{CachedRegistryDist, CachedWheel, IndexUrls};
use pep440_rs::Version;
@ -110,8 +108,8 @@ impl<'a> RegistryWheelIndex<'a> {
) {
for wheel_dir in directories(path.as_ref()) {
match CachedWheel::from_path(&wheel_dir) {
Ok(None) => {}
Ok(Some(dist_info)) => {
None => {}
Some(dist_info) => {
let dist_info = dist_info.into_registry_dist();
// Pick the wheel with the highest priority
@ -125,19 +123,6 @@ impl<'a> RegistryWheelIndex<'a> {
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()
);
}
}
}
}
}