aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-31 21:47:57 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit06163cb8b907e30f8463b2b9700d136c73b19a33 (patch)
treee52b74a82a88c2a4dde16c564f700a12a35020cd /backends
parent8cdde307f7b1d3eff71050817921ea0aa8c318fe (diff)
downloadscummvm-rg350-06163cb8b907e30f8463b2b9700d136c73b19a33.tar.gz
scummvm-rg350-06163cb8b907e30f8463b2b9700d136c73b19a33.tar.bz2
scummvm-rg350-06163cb8b907e30f8463b2b9700d136c73b19a33.zip
CLOUD: Fix SavesSyncRequest to create saves folder
Diffstat (limited to 'backends')
-rw-r--r--backends/cloud/savessyncrequest.cpp33
-rw-r--r--backends/cloud/savessyncrequest.h2
2 files changed, 32 insertions, 3 deletions
diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp
index cf0c427294..d5cb6f6f76 100644
--- a/backends/cloud/savessyncrequest.cpp
+++ b/backends/cloud/savessyncrequest.cpp
@@ -164,10 +164,37 @@ void SavesSyncRequest::directoryListedErrorCallback(Networking::ErrorResponse er
return;
}
- //we're lucky - user just lacks his "/cloud/" folder
+ //we're lucky - user just lacks his "/cloud/" folder - let's create one
+ Common::String dir = _storage->savesDirectoryPath();
+ if (dir.lastChar() == '/') dir.deleteLastChar();
+ debug("creating %s", dir.c_str());
+ _workingRequest = _storage->createDirectory(dir,
+ new Common::Callback<SavesSyncRequest, Storage::BoolResponse>(this, &SavesSyncRequest::directoryCreatedCallback),
+ new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryCreatedErrorCallback)
+ );
+}
+
+void SavesSyncRequest::directoryCreatedCallback(Storage::BoolResponse response) {
+ _workingRequest = nullptr;
+ if (_ignoreCallback) return;
+
+ //stop syncing if failed to create saves directory
+ if (!response.value) {
+ finishError(Networking::ErrorResponse(this, false, true, "", -1));
+ return;
+ }
+
+ //continue with empty files list
Common::Array<StorageFile> files;
- directoryListedCallback(Storage::ListDirectoryResponse(error.request, files));
- //TODO: create it before uploading stuff
+ directoryListedCallback(Storage::ListDirectoryResponse(response.request, files));
+}
+
+void SavesSyncRequest::directoryCreatedErrorCallback(Networking::ErrorResponse error) {
+ _workingRequest = nullptr;
+ if (_ignoreCallback) return;
+
+ //stop syncing if failed to create saves directory
+ finishError(error);
}
void SavesSyncRequest::downloadNextFile() {
diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h
index bf44b70390..0e20159845 100644
--- a/backends/cloud/savessyncrequest.h
+++ b/backends/cloud/savessyncrequest.h
@@ -47,6 +47,8 @@ class SavesSyncRequest: public Networking::Request {
void start();
void directoryListedCallback(Storage::ListDirectoryResponse response);
void directoryListedErrorCallback(Networking::ErrorResponse error);
+ void directoryCreatedCallback(Storage::BoolResponse response);
+ void directoryCreatedErrorCallback(Networking::ErrorResponse error);
void fileDownloadedCallback(Storage::BoolResponse response);
void fileDownloadedErrorCallback(Networking::ErrorResponse error);
void fileUploadedCallback(Storage::UploadResponse response);