You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/08/19 09:53:32 UTC

[incubator-opendal] 01/02: allow append for azblob

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

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

commit bf80ca7556323d4d728f8115c0e3eb05f991fd34
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sat Aug 19 17:46:51 2023 +0800

    allow append for azblob
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 core/src/services/azblob/backend.rs |  7 -------
 core/src/services/azblob/writer.rs  | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs
index e9f956e23..e773d4199 100644
--- a/core/src/services/azblob/backend.rs
+++ b/core/src/services/azblob/backend.rs
@@ -602,13 +602,6 @@ impl Accessor for AzblobBackend {
     }
 
     async fn write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::Writer)> {
-        if args.content_length().is_none() {
-            return Err(Error::new(
-                ErrorKind::Unsupported,
-                "write without content length is not supported",
-            ));
-        }
-
         Ok((
             RpWrite::default(),
             AzblobWriter::new(self.core.clone(), args, path.to_string()),
diff --git a/core/src/services/azblob/writer.rs b/core/src/services/azblob/writer.rs
index 8bf15a146..31a56f27a 100644
--- a/core/src/services/azblob/writer.rs
+++ b/core/src/services/azblob/writer.rs
@@ -166,6 +166,13 @@ impl oio::Write for AzblobWriter {
             self.append_oneshot(bs.len() as u64, AsyncBody::Bytes(bs))
                 .await
         } else {
+            if self.op.content_length().is_none() {
+                return Err(Error::new(
+                    ErrorKind::Unsupported,
+                    "write without content length is not supported",
+                ));
+            }
+
             self.write_oneshot(bs.len() as u64, AsyncBody::Bytes(bs))
                 .await
         }
@@ -175,6 +182,13 @@ impl oio::Write for AzblobWriter {
         if self.op.append() {
             self.append_oneshot(size, AsyncBody::Stream(s)).await
         } else {
+            if self.op.content_length().is_none() {
+                return Err(Error::new(
+                    ErrorKind::Unsupported,
+                    "write without content length is not supported",
+                ));
+            }
+
             self.write_oneshot(size, AsyncBody::Stream(s)).await
         }
     }