diff options
-rw-r--r-- | tokio/src/fs/file.rs | 5 | ||||
-rw-r--r-- | tokio/tests/fs_file.rs | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/tokio/src/fs/file.rs b/tokio/src/fs/file.rs index 8b385117..7c71f483 100644 --- a/tokio/src/fs/file.rs +++ b/tokio/src/fs/file.rs @@ -682,9 +682,8 @@ impl AsyncWrite for File { inner.poll_flush(cx) } - fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> { - // Flush is a noop for files so it's fine not to call it. - Poll::Ready(Ok(())) + fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> { + self.poll_flush(cx) } } diff --git a/tokio/tests/fs_file.rs b/tokio/tests/fs_file.rs index eee9a5b5..d5b56e6e 100644 --- a/tokio/tests/fs_file.rs +++ b/tokio/tests/fs_file.rs @@ -38,6 +38,19 @@ async fn basic_write() { } #[tokio::test] +async fn basic_write_and_shutdown() { + let tempfile = tempfile(); + + let mut file = File::create(tempfile.path()).await.unwrap(); + + file.write_all(HELLO).await.unwrap(); + file.shutdown().await.unwrap(); + + let file = std::fs::read(tempfile.path()).unwrap(); + assert_eq!(file, HELLO); +} + +#[tokio::test] async fn coop() { let mut tempfile = tempfile(); tempfile.write_all(HELLO).unwrap(); |