Use fs_err in more places (#926)

Before:

```
error: Failed to download distributions
  Caused by: Failed to fetch wheel: jaxlib==0.4.23+cuda12.cudnn89
  Caused by: Directory not empty (os error 39)
```

After:

```
error: Failed to download distributions
  Caused by: Failed to fetch wheel: jaxlib==0.4.23+cuda12.cudnn89
  Caused by: failed to rename file from /home/konsti/.cache/puffin/.tmpcG7tVP/jaxlib-0.4.23+cuda12.cudnn89-cp310-cp310-manylinux2014_x86_64.whl to /home/konsti/.cache/puffin/wheels-v0/index/9ff50b883297fa9d/jaxlib/jaxlib-0.4.23+cuda12.cudnn89-cp310-cp310-manylinux2014_x86_64
  Caused by: Directory not empty (os error 39)
```
This commit is contained in:
konsti 2024-01-15 10:39:33 +01:00 committed by GitHub
parent 05029d219f
commit 95f3cca28d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View file

@ -159,7 +159,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
);
fs::create_dir_all(&cache_entry.dir()).await?;
let target = cache_entry.into_path_buf();
tokio::fs::rename(temp_target, &target).await?;
fs_err::tokio::rename(temp_target, &target).await?;
Ok(LocalWheel::Unzipped(UnzippedWheel {
dist: dist.clone(),
@ -184,7 +184,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
);
fs::create_dir_all(&cache_entry.dir()).await?;
let target = cache_entry.into_path_buf();
tokio::fs::rename(temp_target, &target).await?;
fs_err::tokio::rename(temp_target, &target).await?;
let local_wheel = LocalWheel::Unzipped(UnzippedWheel {
dist: dist.clone(),

View file

@ -834,7 +834,7 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
// Download the source distribution to a temporary file.
let sdist_file = temp_dir.path().join(source_dist_filename);
let mut writer = tokio::io::BufWriter::new(
tokio::fs::File::create(&sdist_file)
fs_err::tokio::File::create(&sdist_file)
.await
.map_err(puffin_client::Error::CacheWrite)?,
);

View file

@ -16,9 +16,9 @@ workspace = true
tokio-util = { workspace = true, features = ["compat"] }
async_zip = { workspace = true, features = ["tokio"] }
flate2 = { workspace = true }
fs-err = { workspace = true }
fs-err = { workspace = true, features = ["tokio"] }
rayon = { workspace = true }
tar = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tokio = { workspace = true, features = ["io-util"] }
zip = { workspace = true }

View file

@ -44,12 +44,12 @@ pub async fn unzip_no_seek<R: tokio::io::AsyncRead + Unpin>(
// Create dir or write file
if is_dir {
tokio::fs::create_dir_all(path).await?;
fs_err::tokio::create_dir_all(path).await?;
} else {
if let Some(parent) = path.parent() {
tokio::fs::create_dir_all(parent).await?;
fs_err::tokio::create_dir_all(parent).await?;
}
let file = tokio::fs::File::create(path).await?;
let file = fs_err::tokio::File::create(path).await?;
let mut writer = tokio::io::BufWriter::new(file);
let mut reader = entry.reader_mut().compat();
tokio::io::copy(&mut reader, &mut writer).await?;