Use fs-err in more crates (#100)

Closes https://github.com/astral-sh/puffin/issues/88.
This commit is contained in:
Charlie Marsh
2023-10-16 09:37:58 -04:00
committed by GitHub
parent fa2fd14587
commit 7e8ffeb2df
13 changed files with 33 additions and 14 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ use std::fmt::Write;
use std::path::Path;
use anyhow::{Context, Result};
use fs_err::tokio as fs;
use tracing::debug;
use crate::commands::ExitStatus;
@@ -31,11 +32,11 @@ pub(crate) async fn clean(cache: Option<&Path>, mut printer: Printer) -> Result<
.flatten()
{
if entry.file_type()?.is_dir() {
tokio::fs::remove_dir_all(entry.path())
fs::remove_dir_all(entry.path())
.await
.with_context(|| format!("Failed to clear cache at {}", cache.display()))?;
} else {
tokio::fs::remove_file(entry.path())
fs::remove_file(entry.path())
.await
.with_context(|| format!("Failed to clear cache at {}", cache.display()))?;
}
+1 -1
View File
@@ -1,5 +1,5 @@
use fs_err::File;
use std::fmt::Write;
use std::fs::File;
use std::io::{stdout, BufWriter};
use std::path::Path;
+3 -2
View File
@@ -3,6 +3,7 @@ use std::path::Path;
use anyhow::Result;
use colored::Colorize;
use fs_err::tokio as fs;
use crate::commands::ExitStatus;
use crate::printer::Printer;
@@ -28,8 +29,8 @@ pub(crate) async fn venv(
)?;
// If the path already exists, remove it.
tokio::fs::remove_file(path).await.ok();
tokio::fs::remove_dir_all(path).await.ok();
fs::remove_file(path).await.ok();
fs::remove_dir_all(path).await.ok();
writeln!(
printer,