mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Make clean
non-async (#163)
This commit is contained in:
parent
b665f1489a
commit
370771b28c
2 changed files with 3 additions and 5 deletions
|
@ -2,14 +2,14 @@ use std::fmt::Write;
|
|||
use std::path::Path;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use fs_err::tokio as fs;
|
||||
use fs_err as fs;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::commands::ExitStatus;
|
||||
use crate::printer::Printer;
|
||||
|
||||
/// Clear the cache.
|
||||
pub(crate) async fn clean(cache: Option<&Path>, mut printer: Printer) -> Result<ExitStatus> {
|
||||
pub(crate) fn clean(cache: Option<&Path>, mut printer: Printer) -> Result<ExitStatus> {
|
||||
let Some(cache) = cache else {
|
||||
return Err(anyhow::anyhow!("No cache found"));
|
||||
};
|
||||
|
@ -33,11 +33,9 @@ pub(crate) async fn clean(cache: Option<&Path>, mut printer: Printer) -> Result<
|
|||
{
|
||||
if entry.file_type()?.is_dir() {
|
||||
fs::remove_dir_all(entry.path())
|
||||
.await
|
||||
.with_context(|| format!("Failed to clear cache at {}", cache.display()))?;
|
||||
} else {
|
||||
fs::remove_file(entry.path())
|
||||
.await
|
||||
.with_context(|| format!("Failed to clear cache at {}", cache.display()))?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ async fn main() -> ExitCode {
|
|||
.collect::<Vec<_>>();
|
||||
commands::pip_uninstall(&sources, cache_dir, printer).await
|
||||
}
|
||||
Commands::Clean => commands::clean(cache_dir, printer).await,
|
||||
Commands::Clean => commands::clean(cache_dir, printer),
|
||||
Commands::Freeze => commands::freeze(cache_dir, printer),
|
||||
Commands::Venv(args) => commands::venv(&args.name, args.python.as_deref(), printer).await,
|
||||
Commands::Add(args) => commands::add(&args.name, printer),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue