mirror of https://github.com/astral-sh/uv
Block `tokio::fs` symbols (#15374)
Inspired by #15017, mirror the blocking of `std::fs` symbols in favor of `fs_err` and block `tokio::fs` symbols in favor of `fs_err::tokio`.
This commit is contained in:
parent
f98cb7dece
commit
7a9e07a98e
26
clippy.toml
26
clippy.toml
|
|
@ -17,6 +17,11 @@ disallowed-types = [
|
||||||
"std::fs::File",
|
"std::fs::File",
|
||||||
"std::fs::OpenOptions",
|
"std::fs::OpenOptions",
|
||||||
"std::fs::ReadDir",
|
"std::fs::ReadDir",
|
||||||
|
"tokio::fs::DirBuilder",
|
||||||
|
"tokio::fs::DirEntry",
|
||||||
|
"tokio::fs::File",
|
||||||
|
"tokio::fs::OpenOptions",
|
||||||
|
"tokio::fs::ReadDir",
|
||||||
]
|
]
|
||||||
|
|
||||||
disallowed-methods = [
|
disallowed-methods = [
|
||||||
|
|
@ -38,7 +43,28 @@ disallowed-methods = [
|
||||||
"std::fs::soft_link",
|
"std::fs::soft_link",
|
||||||
"std::fs::symlink_metadata",
|
"std::fs::symlink_metadata",
|
||||||
"std::fs::write",
|
"std::fs::write",
|
||||||
|
"tokio::fs::canonicalize",
|
||||||
|
"tokio::fs::copy",
|
||||||
|
"tokio::fs::create_dir",
|
||||||
|
"tokio::fs::create_dir_all",
|
||||||
|
"tokio::fs::hard_link",
|
||||||
|
"tokio::fs::metadata",
|
||||||
|
"tokio::fs::read",
|
||||||
|
"tokio::fs::read_dir",
|
||||||
|
"tokio::fs::read_link",
|
||||||
|
"tokio::fs::read_to_string",
|
||||||
|
"tokio::fs::remove_dir",
|
||||||
|
"tokio::fs::remove_dir_all",
|
||||||
|
"tokio::fs::remove_file",
|
||||||
|
"tokio::fs::rename",
|
||||||
|
"tokio::fs::set_permissions",
|
||||||
|
"tokio::fs::symlink_metadata",
|
||||||
|
"tokio::fs::try_exists",
|
||||||
|
"tokio::fs::write",
|
||||||
{ path = "std::os::unix::fs::symlink", allow-invalid = true },
|
{ path = "std::os::unix::fs::symlink", allow-invalid = true },
|
||||||
{ path = "std::os::windows::fs::symlink_dir", allow-invalid = true },
|
{ path = "std::os::windows::fs::symlink_dir", allow-invalid = true },
|
||||||
{ path = "std::os::windows::fs::symlink_file", allow-invalid = true },
|
{ path = "std::os::windows::fs::symlink_file", allow-invalid = true },
|
||||||
|
{ path = "tokio::fs::symlink", allow-invalid = true },
|
||||||
|
{ path = "tokio::fs::symlink_dir", allow-invalid = true },
|
||||||
|
{ path = "tokio::fs::symlink_file", allow-invalid = true },
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,10 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
|
||||||
// Download the wheel to a temporary file.
|
// Download the wheel to a temporary file.
|
||||||
let temp_file = tempfile::tempfile_in(self.build_context.cache().root())
|
let temp_file = tempfile::tempfile_in(self.build_context.cache().root())
|
||||||
.map_err(Error::CacheWrite)?;
|
.map_err(Error::CacheWrite)?;
|
||||||
let mut writer = tokio::io::BufWriter::new(tokio::fs::File::from_std(temp_file));
|
let mut writer = tokio::io::BufWriter::new(fs_err::tokio::File::from_std(
|
||||||
|
// It's an unnamed file on Linux so that's the best approximation.
|
||||||
|
fs_err::File::from_parts(temp_file, self.build_context.cache().root()),
|
||||||
|
));
|
||||||
|
|
||||||
match progress {
|
match progress {
|
||||||
Some((reporter, progress)) => {
|
Some((reporter, progress)) => {
|
||||||
|
|
|
||||||
|
|
@ -1799,7 +1799,7 @@ pub async fn download_to_disk(url: &str, path: &Path) {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut file = tokio::fs::File::create(path).await.unwrap();
|
let mut file = fs_err::tokio::File::create(path).await.unwrap();
|
||||||
let mut stream = response.bytes_stream();
|
let mut stream = response.bytes_stream();
|
||||||
while let Some(chunk) = stream.next().await {
|
while let Some(chunk) = stream.next().await {
|
||||||
file.write_all(&chunk.unwrap()).await.unwrap();
|
file.write_all(&chunk.unwrap()).await.unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue