Skip to content

Commit

Permalink
fix clippy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohaiyuan committed Feb 5, 2025
1 parent 4f1da83 commit 79720f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
5 changes: 3 additions & 2 deletions core/src/services/swift/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ impl Access for SwiftBackend {

match status {
StatusCode::OK | StatusCode::NO_CONTENT => {
let meta = parse_into_metadata(path, resp.headers())?;
let user_meta = parse_prefixed_headers(headers, "x-swift-meta-");
let headers = resp.headers();
let mut meta = parse_into_metadata(path, headers)?;
let user_meta = parse_prefixed_headers(headers, "X-OBJECT-META-");
if !user_meta.is_empty() {
meta.with_user_metadata(user_meta);
}
Expand Down
22 changes: 8 additions & 14 deletions core/src/services/swift/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ impl SwiftCore {

req = req.header("X-Auth-Token", &self.token);

// Set user metadata headers.
if let Some(user_metadata) = args.user_metadata() {
for (key, value) in user_metadata {
req = req.header(format!("x-swift-meta-{key}"), value)
}
}

let body = Buffer::new();

let req = req.body(body).map_err(new_request_build_error)?;
Expand Down Expand Up @@ -98,13 +91,6 @@ impl SwiftCore {
url += &format!("&marker={}", marker);
}

// Set user metadata headers.
if let Some(user_metadata) = args.user_metadata() {
for (key, value) in user_metadata {
req = req.header(format!("x-swift-meta-{key}"), value)
}
}

let mut req = Request::get(&url);

req = req.header("X-Auth-Token", &self.token);
Expand All @@ -118,6 +104,7 @@ impl SwiftCore {
&self,
path: &str,
length: u64,
args: &OpWrite,
body: Buffer,
) -> Result<Response<Buffer>> {
let p = build_abs_path(&self.root, path);
Expand All @@ -130,6 +117,13 @@ impl SwiftCore {

let mut req = Request::put(&url);

// Set user metadata headers.
if let Some(user_metadata) = args.user_metadata() {
for (key, value) in user_metadata {
req = req.header(format!("X-Object-Meta-{key}"), value)
}
}

req = req.header("X-Auth-Token", &self.token);
req = req.header(header::CONTENT_LENGTH, length);

Expand Down
7 changes: 4 additions & 3 deletions core/src/services/swift/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ use crate::*;

pub struct SwiftWriter {
core: Arc<SwiftCore>,
op: OpWrite,
path: String,
}

impl SwiftWriter {
pub fn new(core: Arc<SwiftCore>, _op: OpWrite, path: String) -> Self {
SwiftWriter { core, path }
pub fn new(core: Arc<SwiftCore>, op: OpWrite, path: String) -> Self {
SwiftWriter { core, op, path }
}
}

impl oio::OneShotWrite for SwiftWriter {
async fn write_once(&self, bs: Buffer) -> Result<()> {
let resp = self
.core
.swift_create_object(&self.path, bs.len() as u64, bs)
.swift_create_object(&self.path, bs.len() as u64, &self.op, bs)
.await?;

let status = resp.status();
Expand Down

0 comments on commit 79720f8

Please sign in to comment.