This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch poll-write
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 2b75cf72f79145ca37c03da890d1d186a58f7dee
Author: Xuanwo <[email protected]>
AuthorDate: Fri Sep 8 16:10:34 2023 +0800

    Fix ipmfs
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/services/ipmfs/backend.rs |  4 ++--
 core/src/services/ipmfs/writer.rs  | 17 +++++------------
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/core/src/services/ipmfs/backend.rs 
b/core/src/services/ipmfs/backend.rs
index aebab57e5..eda6d8895 100644
--- a/core/src/services/ipmfs/backend.rs
+++ b/core/src/services/ipmfs/backend.rs
@@ -65,7 +65,7 @@ impl IpmfsBackend {
 impl Accessor for IpmfsBackend {
     type Reader = IncomingAsyncBody;
     type BlockingReader = ();
-    type Writer = IpmfsWriter;
+    type Writer = oio::OneShotWriter<IpmfsWriter>;
     type BlockingWriter = ();
     type Pager = IpmfsPager;
     type BlockingPager = ();
@@ -131,7 +131,7 @@ impl Accessor for IpmfsBackend {
 
         Ok((
             RpWrite::default(),
-            IpmfsWriter::new(self.clone(), path.to_string()),
+            oio::OneShotWriter::new(IpmfsWriter::new(self.clone(), 
path.to_string())),
         ))
     }
 
diff --git a/core/src/services/ipmfs/writer.rs 
b/core/src/services/ipmfs/writer.rs
index dcecb66d3..e3395dfaf 100644
--- a/core/src/services/ipmfs/writer.rs
+++ b/core/src/services/ipmfs/writer.rs
@@ -17,9 +17,11 @@
 
 use async_trait::async_trait;
 use http::StatusCode;
+use std::task::{Context, Poll};
 
 use super::backend::IpmfsBackend;
 use super::error::parse_error;
+use crate::raw::oio::WriteBuf;
 use crate::raw::*;
 use crate::*;
 
@@ -35,9 +37,8 @@ impl IpmfsWriter {
     }
 }
 
-#[async_trait]
-impl oio::Write for IpmfsWriter {
-    fn poll_write(&mut self, cx: &mut Context<'_>, bs: &dyn oio::WriteBuf) -> 
Poll<Result<usize>> {
+impl oio::OneShotWrite for IpmfsWriter {
+    async fn write_once(&self, bs: &dyn WriteBuf) -> Result<()> {
         let size = bs.remaining();
         let resp = self
             .backend
@@ -49,17 +50,9 @@ impl oio::Write for IpmfsWriter {
         match status {
             StatusCode::CREATED | StatusCode::OK => {
                 resp.into_body().consume().await?;
-                Ok(size)
+                Ok(())
             }
             _ => Err(parse_error(resp).await?),
         }
     }
-
-    fn poll_abort(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> {
-        Ok(())
-    }
-
-    fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> {
-        Ok(())
-    }
 }

Reply via email to