Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(services/dropbox): fix dropbox test failed #4317

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions core/src/services/dropbox/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashMap;
use std::default::Default;
use std::fmt::Debug;
use std::fmt::Formatter;
Expand All @@ -37,7 +38,6 @@ use serde::Serialize;
use tokio::sync::Mutex;

use super::error::parse_error;
use super::error::DropboxErrorResponse;
use crate::raw::*;
use crate::*;

Expand Down Expand Up @@ -337,10 +337,15 @@ impl DropboxCore {
(path, Ok(RpDelete::default().into()))
}
"failure" => {
let error = entry.error.expect("error should be present");
let error = entry.failure.expect("error should be present");
let error_cause = &error
.failure_cause_map
.get(&error.tag)
.expect("error should be present")
.tag;
let err = Error::new(
ErrorKind::Unexpected,
&format!("delete failed with error {}", error.error_summary),
&format!("delete failed with error {} {}", error.tag, error_cause),
);
("".to_string(), Err(err))
}
Expand Down Expand Up @@ -515,5 +520,26 @@ pub struct DropboxDeleteBatchResponseEntry {
#[serde(rename(deserialize = ".tag"))]
pub tag: String,
pub metadata: Option<DropboxMetadataResponse>,
pub error: Option<DropboxErrorResponse>,
pub failure: Option<DropboxDeleteBatchFailureResponse>,
}

#[derive(Default, Debug, Deserialize)]
#[serde(default)]
pub struct DropboxDeleteBatchFailureResponse {
#[serde(rename(deserialize = ".tag"))]
pub tag: String,
// During the batch deletion process, Dropbox returns
// part of the error information in the form of a JSON key.
// Since it is impossible to determine the JSON key in advance,
// the error information is parsed into a HashMap here.
// The key of the HashMap is equal to the value of the tag above.
#[serde(flatten)]
pub failure_cause_map: HashMap<String, DropboxDeleteBatchFailureResponseCause>,
}

#[derive(Default, Debug, Deserialize)]
#[serde(default)]
pub struct DropboxDeleteBatchFailureResponseCause {
#[serde(rename(deserialize = ".tag"))]
pub tag: String,
}
Loading