mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
uv-client: remove benign WARN log message
A WARN log was being emitted for a "broken cache entry" in the case where the cache entry simply doesn't exist. But this is totally fine and expected. So we detect the kind of error that occurred and emit a TRACE if the file simply didn't exist.
This commit is contained in:
parent
9a720a87c8
commit
634d593127
2 changed files with 20 additions and 5 deletions
|
@ -344,11 +344,17 @@ impl CachedClient {
|
|||
{
|
||||
Ok(data) => Some(data),
|
||||
Err(err) => {
|
||||
warn!(
|
||||
"Broken cache policy entry at {}, removing: {err}",
|
||||
cache_entry.path().display()
|
||||
);
|
||||
let _ = fs_err::tokio::remove_file(&cache_entry.path()).await;
|
||||
// When we know the cache entry doesn't exist, then things are
|
||||
// normal and we shouldn't emit a WARN.
|
||||
if err.kind().is_file_not_exists() {
|
||||
trace!("No cache entry exists for {}", cache_entry.path().display());
|
||||
} else {
|
||||
warn!(
|
||||
"Broken cache policy entry at {}, removing: {err}",
|
||||
cache_entry.path().display()
|
||||
);
|
||||
let _ = fs_err::tokio::remove_file(&cache_entry.path()).await;
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,15 @@ pub enum ErrorKind {
|
|||
}
|
||||
|
||||
impl ErrorKind {
|
||||
/// Returns true if this error kind corresponds to an I/O "not found"
|
||||
/// error.
|
||||
pub(crate) fn is_file_not_exists(&self) -> bool {
|
||||
let ErrorKind::Io(ref err) = *self else {
|
||||
return false;
|
||||
};
|
||||
matches!(err.kind(), std::io::ErrorKind::NotFound)
|
||||
}
|
||||
|
||||
pub(crate) fn from_middleware(err: reqwest_middleware::Error) -> Self {
|
||||
if let reqwest_middleware::Error::Middleware(ref underlying) = err {
|
||||
if let Some(err) = underlying.downcast_ref::<OfflineError>() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue