diff options
Diffstat (limited to 'backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp')
-rw-r--r-- | backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp index 6cc6801bc0..97090b44f8 100644 --- a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp +++ b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp @@ -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; |