Skip to content

Commit

Permalink
Update the dependency library and adapt to changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed Aug 15, 2022
1 parent e2d8b02 commit 8fb52fa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/db/reldb_client.rs
Expand Up @@ -962,7 +962,7 @@ where
};
let mut table_name = String::new();
if let ast::Statement::Query(query) = ast {
if let SetExpr::Select(select) = (*query).body {
if let SetExpr::Select(select) = query.body.as_ref() {
if let TableFactor::Table { name, .. } = &select.from[0].relation {
table_name = name.0[0].value.clone();
}
Expand Down
42 changes: 29 additions & 13 deletions src/os/os_client.rs
Expand Up @@ -49,6 +49,7 @@ impl TardisOSClient {
secret_key: Some(sk.to_string()),
security_token: None,
session_token: None,
expiration: None,
};
let default_bucket = if !default_bucket.is_empty() {
Some(Bucket::new(default_bucket, region.clone(), credentials.clone())?.with_path_style())
Expand Down Expand Up @@ -174,45 +175,60 @@ impl TardisOSOperations for TardisOSS3Client {

async fn object_create(&self, path: &str, content: &[u8], content_type: Option<&str>, bucket_name: Option<&str>) -> TardisResult<()> {
let bucket = self.get_bucket(bucket_name)?;
let (_, code) = if let Some(content_type) = content_type {
let response_data = if let Some(content_type) = content_type {
bucket.put_object_with_content_type(path, content, content_type).await?
} else {
bucket.put_object(path, content).await?
};
if code == 200 {
if response_data.status_code() == 200 {
Ok(())
} else {
Err(TardisError::custom(
&code.to_string(),
&format!("[Tardis.OSClient] Failed to create object {}:{} with error [{}]", bucket.name, path, code),
&response_data.status_code().to_string(),
&format!(
"[Tardis.OSClient] Failed to create object {}:{} with error [{}]",
bucket.name,
path,
std::str::from_utf8(response_data.bytes())?
),
"-1-tardis-os-create-object-error",
))
}
}

async fn object_get(&self, path: &str, bucket_name: Option<&str>) -> TardisResult<Vec<u8>> {
let bucket = self.get_bucket(bucket_name)?;
let (data, code) = bucket.get_object(path).await?;
if code == 200 {
Ok(data)
let response_data = bucket.get_object(path).await?;
if response_data.status_code() == 200 {
Ok(response_data.bytes().to_vec())
} else {
Err(TardisError::custom(
&code.to_string(),
&format!("[Tardis.OSClient] Failed to get object {}:{} with error [{}]", bucket.name, path, code),
&response_data.status_code().to_string(),
&format!(
"[Tardis.OSClient] Failed to get object {}:{} with error [{}]",
bucket.name,
path,
std::str::from_utf8(response_data.bytes())?
),
"-1-tardis-os-get-object-error",
))
}
}

async fn object_delete(&self, path: &str, bucket_name: Option<&str>) -> TardisResult<()> {
let bucket = self.get_bucket(bucket_name)?;
let (_, code) = bucket.delete_object(path).await?;
if code == 200 || code == 204 {
let response_data = bucket.delete_object(path).await?;
if response_data.status_code() == 200 || response_data.status_code() == 204 {
Ok(())
} else {
Err(TardisError::custom(
&code.to_string(),
&format!("[Tardis.OSClient] Failed to delete object {}:{} with error [{}]", bucket.name, path, code),
&response_data.status_code().to_string(),
&format!(
"[Tardis.OSClient] Failed to delete object {}:{} with error [{}]",
bucket.name,
path,
std::str::from_utf8(response_data.bytes())?
),
"-1-tardis-os-delete-object-error",
))
}
Expand Down
2 changes: 0 additions & 2 deletions tardis-macros/examples/struct_copy_example.rs
@@ -1,5 +1,3 @@
use tardis_macros::sql;

fn main() {
// TODO
}

0 comments on commit 8fb52fa

Please sign in to comment.