CLOUD: Update Dropbox Requests

Adding more JSON checks there.
This commit is contained in:
Alexander Tkachev 2016-07-26 14:10:54 +06:00
parent a2e0199727
commit 6be736b5ed
2 changed files with 65 additions and 14 deletions

View file

@ -79,19 +79,27 @@ void DropboxCreateDirectoryRequest::responseCallback(Networking::JsonResponse re
if (rq && rq->getNetworkReadStream())
error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode();
if (!json) {
warning("DropboxCreateDirectoryRequest: NULL passed instead of JSON");
if (json == nullptr) {
error.response = "Failed to parse JSON, null passed!";
finishError(error);
return;
}
if (!json->isObject()) {
error.response = "Passed JSON is not an object!";
finishError(error);
delete json;
return;
}
Common::JSONObject info = json->asObject();
if (info.contains("id")) {
finishCreation(true);
} else {
if (info.contains("error_summary") && info.getVal("error_summary")->isString()) {
if (Networking::CurlJsonRequest::jsonContainsString(info, "error_summary", "DropboxCreateDirectoryRequest")) {
Common::String summary = info.getVal("error_summary")->asString();
if (summary.contains("path") && summary.contains("conflict") && summary.contains("folder")) {
// existing directory - not an error for CreateDirectoryRequest
finishCreation(false);
delete json;
return;