update changelogs

This commit is contained in:
Rob Ede 2021-11-22 00:38:04 +00:00
parent fae8956265
commit a717ed7e75
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
8 changed files with 37 additions and 41 deletions

View File

@ -143,8 +143,6 @@ actix-web-actors = { path = "actix-web-actors" }
actix-web-codegen = { path = "actix-web-codegen" }
awc = { path = "awc" }
actix-rt = { git = "https://github.com/actix/actix-net.git" }
[[test]]
name = "test_server"
required-features = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"]

View File

@ -2,7 +2,11 @@
## Unreleased - 2021-xx-xx
* Add crate feature `experimental-io-uring`, enabling async file I/O to be utilized. This feature is only available on Linux OSes with recent kernel versions. This feature is semver-exempt. [#2408]
* Add `NamedFile::open_async`. [#2408]
* Fix 304 Not Modified responses to omit the Content-Length header, as per the spec. [#2453]
* The `Responder` impl for `NamedFile` now has a boxed future associated type. [#2408]
* The `Service` impl for `NamedFileService` now has a boxed future associated type. [#2408]
* Add `impl Clone` for `FilesService`. [#2408]
[#2408]: https://github.com/actix/actix-web/pull/2408
[#2453]: https://github.com/actix/actix-web/pull/2453

View File

@ -14,9 +14,8 @@ use pin_project_lite::pin_project;
use super::named::File;
pin_project! {
/// Adapter to read a `std::file::File` in chunks.
#[doc(hidden)]
/// A helper created from a `std::fs::File` which reads the file
/// chunk-by-chunk on a `ThreadPool`.
pub struct ChunkedReadFile<F, Fut> {
size: u64,
offset: u64,
@ -32,13 +31,8 @@ pin_project! {
#[project = ChunkedReadFileStateProj]
#[project_replace = ChunkedReadFileStateProjReplace]
enum ChunkedReadFileState<Fut> {
File {
file: Option<File>,
},
Future {
#[pin]
fut: Fut
}
File { file: Option<File>, },
Future { #[pin] fut: Fut },
}
}
@ -47,13 +41,8 @@ pin_project! {
#[project = ChunkedReadFileStateProj]
#[project_replace = ChunkedReadFileStateProjReplace]
enum ChunkedReadFileState<Fut> {
File {
file: Option<(File, BytesMut)>,
},
Future {
#[pin]
fut: Fut
}
File { file: Option<(File, BytesMut)> },
Future { #[pin] fut: Fut },
}
}
@ -88,7 +77,7 @@ async fn chunked_read_file_callback(
offset: u64,
max_bytes: usize,
) -> Result<(File, Bytes), Error> {
use io::{Read, Seek};
use io::{Read as _, Seek as _};
let res = actix_web::rt::task::spawn_blocking(move || {
let mut buf = Vec::with_capacity(max_bytes);
@ -117,6 +106,7 @@ async fn chunked_read_file_callback(
mut bytes_mut: BytesMut,
) -> io::Result<(File, Bytes, BytesMut)> {
bytes_mut.reserve(max_bytes);
let (res, mut bytes_mut) = file.read_at(bytes_mut, offset).await;
let n_bytes = res?;

View File

@ -33,12 +33,12 @@ mod path_buf;
mod range;
mod service;
pub use crate::chunked::ChunkedReadFile;
pub use crate::directory::Directory;
pub use crate::files::Files;
pub use crate::named::NamedFile;
pub use crate::range::HttpRange;
pub use crate::service::FilesService;
pub use self::chunked::ChunkedReadFile;
pub use self::directory::Directory;
pub use self::files::Files;
pub use self::named::NamedFile;
pub use self::range::HttpRange;
pub use self::service::FilesService;
use self::directory::{directory_listing, DirectoryRenderer};
use self::error::FilesError;
@ -81,7 +81,6 @@ mod tests {
};
use super::*;
use crate::named::File;
#[actix_web::test]

View File

@ -90,7 +90,7 @@ impl fmt::Debug for NamedFile {
"file",
#[cfg(feature = "experimental-io-uring")]
{
&"File"
&"tokio_uring::File"
},
#[cfg(not(feature = "experimental-io-uring"))]
{
@ -120,7 +120,6 @@ impl NamedFile {
/// `ContentDisposition` headers.
///
/// # Examples
///
/// ```ignore
/// use actix_files::NamedFile;
/// use std::io::{self, Write};
@ -194,12 +193,14 @@ impl NamedFile {
let fd = file.as_raw_fd();
// SAFETY: fd is borrowed and lives longer than the unsafe block.
// SAFETY: fd is borrowed and lives longer than the unsafe block
unsafe {
let fs = std::fs::File::from_raw_fd(fd);
let res = fs.metadata();
std::mem::forget(fs);
res?
let file = std::fs::File::from_raw_fd(fd);
let md = file.metadata();
// SAFETY: forget the fd before exiting block in success or error case but don't
// run destructor (that would close file handle)
std::mem::forget(file);
md?
}
}
};
@ -224,10 +225,8 @@ impl NamedFile {
/// Attempts to open a file in read-only mode.
///
/// # Examples
///
/// ```
/// use actix_files::NamedFile;
///
/// let file = NamedFile::open("foo.txt");
/// ```
pub fn open<P: AsRef<Path>>(path: P) -> io::Result<NamedFile> {
@ -237,11 +236,12 @@ impl NamedFile {
/// Attempts to open a file asynchronously in read-only mode.
///
/// # Examples
/// When the `experimental-io-uring` crate feature is enabled, this will be async.
/// Otherwise, it will be just like [`open`][Self::open].
///
/// # Examples
/// ```
/// use actix_files::NamedFile;
///
/// # async fn open() {
/// let file = NamedFile::open_async("foo.txt").await.unwrap();
/// # }
@ -271,7 +271,6 @@ impl NamedFile {
/// Retrieve the path of this file.
///
/// # Examples
///
/// ```
/// # use std::io;
/// use actix_files::NamedFile;
@ -584,13 +583,13 @@ fn none_match(etag: Option<&header::EntityTag>, req: &HttpRequest) -> bool {
impl Deref for NamedFile {
type Target = File;
fn deref(&self) -> &File {
fn deref(&self) -> &Self::Target {
&self.file
}
}
impl DerefMut for NamedFile {
fn deref_mut(&mut self) -> &mut File {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.file
}
}

View File

@ -17,7 +17,7 @@ use crate::{
/// Assembled file serving service.
#[derive(Clone)]
pub struct FilesService(pub Rc<FilesServiceInner>);
pub struct FilesService(pub(crate) Rc<FilesServiceInner>);
impl Deref for FilesService {
type Target = FilesServiceInner;

View File

@ -1,6 +1,9 @@
# Changes
## Unreleased - 2021-xx-xx
* Fix compatibility with experimental `io-uring` feature of `actix-rt`. [#2408]
[#2408]: https://github.com/actix/actix-web/pull/2408
## 3.0.0-beta.6 - 2021-11-15

View File

@ -1,6 +1,9 @@
# Changes
## Unreleased - 2021-xx-xx
* Fix compatibility with experimental `io-uring` feature of `actix-rt`. [#2408]
[#2408]: https://github.com/actix/actix-web/pull/2408
## 0.1.0-beta.6 - 2021-11-15