This commit is contained in:
Joel Wurtz 2025-03-10 14:54:13 -07:00 committed by GitHub
commit 8ccb787a6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 13 deletions

View File

@ -3,6 +3,7 @@
## Unreleased
- Minimum supported Rust version (MSRV) is now 1.75.
- Avoid spawning a thread for each file which does more harm than good
## 0.6.6

View File

@ -80,7 +80,6 @@ async fn chunked_read_file_callback(
) -> Result<(File, Bytes), Error> {
use io::{Read as _, Seek as _};
let res = actix_web::web::block(move || {
let mut buf = Vec::with_capacity(max_bytes);
file.seek(io::SeekFrom::Start(offset))?;
@ -88,14 +87,10 @@ async fn chunked_read_file_callback(
let n_bytes = file.by_ref().take(max_bytes as u64).read_to_end(&mut buf)?;
if n_bytes == 0 {
Err(io::Error::from(io::ErrorKind::UnexpectedEof))
Err(Error::from(io::Error::from(io::ErrorKind::UnexpectedEof)))
} else {
Ok((file, Bytes::from(buf)))
}
})
.await??;
Ok(res)
}
#[cfg(feature = "experimental-io-uring")]