This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 7d5524f35 fix: call `flush` before `sync_all` (#3053)
7d5524f35 is described below
commit 7d5524f35f29f7eda8131e8b0873590b7cbe34ab
Author: Weny Xu <[email protected]>
AuthorDate: Wed Sep 13 19:20:08 2023 +0900
fix: call `flush` before `sync_all` (#3053)
---
core/src/services/fs/writer.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/core/src/services/fs/writer.rs b/core/src/services/fs/writer.rs
index 6087b622c..5b1ae953e 100644
--- a/core/src/services/fs/writer.rs
+++ b/core/src/services/fs/writer.rs
@@ -26,6 +26,7 @@ use async_trait::async_trait;
use futures::future::BoxFuture;
use futures::FutureExt;
use tokio::io::AsyncWrite;
+use tokio::io::AsyncWriteExt;
use super::error::parse_io_error;
use crate::raw::*;
@@ -73,10 +74,11 @@ impl oio::Write for FsWriter<tokio::fs::File> {
return Poll::Ready(res);
}
- let f = self.f.take().expect("FsWriter must be initialized");
+ let mut f = self.f.take().expect("FsWriter must be initialized");
let tmp_path = self.tmp_path.clone();
let target_path = self.target_path.clone();
self.fut = Some(Box::pin(async move {
+ f.flush().await.map_err(parse_io_error)?;
f.sync_all().await.map_err(parse_io_error)?;
if let Some(tmp_path) = &tmp_path {