aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/onedrive
diff options
context:
space:
mode:
Diffstat (limited to 'backends/cloud/onedrive')
-rw-r--r--backends/cloud/onedrive/onedrivestorage.cpp9
-rw-r--r--backends/cloud/onedrive/onedrivestorage.h1
-rw-r--r--backends/cloud/onedrive/onedrivetokenrefresher.cpp22
3 files changed, 28 insertions, 4 deletions
diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp
index 19e497258b..b0f4f7be65 100644
--- a/backends/cloud/onedrive/onedrivestorage.cpp
+++ b/backends/cloud/onedrive/onedrivestorage.cpp
@@ -35,6 +35,7 @@
#include "common/json.h"
#include "common/system.h"
#include <curl/curl.h>
+#include "../savessyncrequest.h"
namespace Cloud {
namespace OneDrive {
@@ -205,6 +206,11 @@ void OneDriveStorage::printFiles(FileArrayResponse pair) {
debug("\t%s", files[i].path().c_str());
}
+void OneDriveStorage::printBool(BoolResponse pair) {
+ debug("bool: %s", pair.value ? "true" : "false");
+}
+
+
Networking::Request *OneDriveStorage::syncSaves(BoolCallback callback) {
//this is not the real syncSaves() implementation
/*
@@ -213,7 +219,8 @@ Networking::Request *OneDriveStorage::syncSaves(BoolCallback callback) {
request->addHeader("Authorization: bearer " + _token);
return ConnMan.addRequest(request);
*/
- return downloadFolder("subfolder", "local/onedrive/subfolder_downloaded", new Common::Callback<OneDriveStorage, FileArrayResponse>(this, &OneDriveStorage::printFiles), false);
+ //return downloadFolder("subfolder", "local/onedrive/subfolder_downloaded", new Common::Callback<OneDriveStorage, FileArrayResponse>(this, &OneDriveStorage::printFiles), false);
+ return ConnMan.addRequest(new SavesSyncRequest(this, new Common::Callback<OneDriveStorage, BoolResponse>(this, &OneDriveStorage::printBool)));
}
OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) {
diff --git a/backends/cloud/onedrive/onedrivestorage.h b/backends/cloud/onedrive/onedrivestorage.h
index 55d039653a..43675fbfa5 100644
--- a/backends/cloud/onedrive/onedrivestorage.h
+++ b/backends/cloud/onedrive/onedrivestorage.h
@@ -52,6 +52,7 @@ class OneDriveStorage: public Cloud::Storage {
void printJson(Networking::JsonResponse pair);
void fileDownloaded(BoolResponse pair);
void printFiles(FileArrayResponse pair);
+ void printBool(BoolResponse pair);
void fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse pair);
public:
diff --git a/backends/cloud/onedrive/onedrivetokenrefresher.cpp b/backends/cloud/onedrive/onedrivetokenrefresher.cpp
index d932f9ab17..a0c41ff471 100644
--- a/backends/cloud/onedrive/onedrivetokenrefresher.cpp
+++ b/backends/cloud/onedrive/onedrivetokenrefresher.cpp
@@ -60,7 +60,7 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) {
if (!json) {
//notify user of failure
warning("OneDriveTokenRefresher: got NULL instead of JSON");
- CurlJsonRequest::finish();
+ CurlJsonRequest::finishJson(nullptr);
return;
}
@@ -72,8 +72,24 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) {
}
Common::JSONObject error = result.getVal("error")->asObject();
- debug("code = %s", error.getVal("code")->asString().c_str());
- debug("message = %s", error.getVal("message")->asString().c_str());
+ bool irrecoverable = true;
+
+ if (error.contains("code")) {
+ Common::String code = error.getVal("code")->asString();
+ debug("code = %s", code.c_str());
+ //if (code == "itemNotFound") irrecoverable = true;
+ }
+
+ if (error.contains("message")) {
+ Common::String message = error.getVal("message")->asString();
+ debug("message = %s", message.c_str());
+ }
+
+ if (irrecoverable) {
+ CurlJsonRequest::finishJson(nullptr);
+ return;
+ }
+
pause();
delete json;
_parentStorage->getAccessToken(new Common::Callback<OneDriveTokenRefresher, Storage::BoolResponse>(this, &OneDriveTokenRefresher::tokenRefreshed));