Skip to content

Commit

Permalink
feat(services/azblob): Rewrite the method signatures using OpWrite (#…
Browse files Browse the repository at this point in the history
…3068)

* feat(services/azblob)!: Rewrite the method signatures using OpWrite

* chore(services/azblob): use OpWrite::default instead of Default::default
  • Loading branch information
acehinnnqru authored Sep 14, 2023
1 parent da6b45f commit 6187b6d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
19 changes: 12 additions & 7 deletions core/src/services/azblob/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,12 @@ impl Accessor for AzblobBackend {
}

async fn create_dir(&self, path: &str, _: OpCreateDir) -> Result<RpCreateDir> {
let mut req =
self.core
.azblob_put_blob_request(path, Some(0), None, None, AsyncBody::Empty)?;
let mut req = self.core.azblob_put_blob_request(
path,
Some(0),
&OpWrite::default(),
AsyncBody::Empty,
)?;

self.core.sign(&mut req).await?;

Expand Down Expand Up @@ -682,10 +685,12 @@ impl Accessor for AzblobBackend {
v.if_match(),
v.override_content_disposition(),
)?,
PresignOperation::Write(_) => {
self.core
.azblob_put_blob_request(path, None, None, None, AsyncBody::Empty)?
}
PresignOperation::Write(_) => self.core.azblob_put_blob_request(
path,
None,
&OpWrite::default(),
AsyncBody::Empty,
)?,
};

self.core.sign_query(&mut req).await?;
Expand Down
14 changes: 6 additions & 8 deletions core/src/services/azblob/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ impl AzblobCore {
&self,
path: &str,
size: Option<u64>,
content_type: Option<&str>,
cache_control: Option<&str>,
args: &OpWrite,
body: AsyncBody,
) -> Result<Request<AsyncBody>> {
let p = build_abs_path(&self.root, path);
Expand All @@ -263,14 +262,14 @@ impl AzblobCore {
// Set SSE headers.
req = self.insert_sse_headers(req);

if let Some(cache_control) = cache_control {
if let Some(cache_control) = args.cache_control() {
req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, cache_control);
}
if let Some(size) = size {
req = req.header(CONTENT_LENGTH, size)
}

if let Some(ty) = content_type {
if let Some(ty) = args.content_type() {
req = req.header(CONTENT_TYPE, ty)
}

Expand Down Expand Up @@ -305,8 +304,7 @@ impl AzblobCore {
pub fn azblob_init_appendable_blob_request(
&self,
path: &str,
content_type: Option<&str>,
cache_control: Option<&str>,
args: &OpWrite,
) -> Result<Request<AsyncBody>> {
let p = build_abs_path(&self.root, path);

Expand All @@ -330,11 +328,11 @@ impl AzblobCore {
"AppendBlob",
);

if let Some(ty) = content_type {
if let Some(ty) = args.content_type() {
req = req.header(CONTENT_TYPE, ty)
}

if let Some(cache_control) = cache_control {
if let Some(cache_control) = args.cache_control() {
req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, cache_control);
}

Expand Down
11 changes: 4 additions & 7 deletions core/src/services/azblob/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ impl oio::OneShotWrite for AzblobWriter {
let mut req = self.core.azblob_put_blob_request(
&self.path,
Some(bs.len() as u64),
self.op.content_type(),
self.op.cache_control(),
&self.op,
AsyncBody::ChunkedBytes(bs),
)?;

Expand Down Expand Up @@ -95,11 +94,9 @@ impl oio::AppendObjectWrite for AzblobWriter {
Ok(parse_content_length(headers)?.unwrap_or_default())
}
StatusCode::NOT_FOUND => {
let mut req = self.core.azblob_init_appendable_blob_request(
&self.path,
self.op.content_type(),
self.op.cache_control(),
)?;
let mut req = self
.core
.azblob_init_appendable_blob_request(&self.path, &self.op)?;

self.core.sign(&mut req).await?;

Expand Down

0 comments on commit 6187b6d

Please sign in to comment.