Make clean non-async (#163)

This commit is contained in:
Charlie Marsh 2023-10-21 23:54:13 -04:00 committed by GitHub
parent b665f1489a
commit 370771b28c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -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()))?;
}
}

View file

@ -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),