aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/storage.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-13 12:32:33 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit0aea8db7e1a59e8cf88436f78019685c9aff6332 (patch)
treef1ffcc4e152a7f0dde1481a1d1b46ceded5cfab8 /backends/cloud/storage.cpp
parentca0b58513d572419c52ba28ca09f4a086c543893 (diff)
downloadscummvm-rg350-0aea8db7e1a59e8cf88436f78019685c9aff6332.tar.gz
scummvm-rg350-0aea8db7e1a59e8cf88436f78019685c9aff6332.tar.bz2
scummvm-rg350-0aea8db7e1a59e8cf88436f78019685c9aff6332.zip
CLOUD: Make Storage::savesSync() restart
If Storage::syncSaves() is called when sync is running, another sync would be automatically scheduled in the end of the current one. That could be helpful when we want to specify that we changed something during sync (created new save slot, for example).
Diffstat (limited to 'backends/cloud/storage.cpp')
-rw-r--r--backends/cloud/storage.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/backends/cloud/storage.cpp b/backends/cloud/storage.cpp
index 08ab9e9c90..b98f213327 100644
--- a/backends/cloud/storage.cpp
+++ b/backends/cloud/storage.cpp
@@ -52,12 +52,18 @@ Networking::Request *Storage::addRequest(Networking::Request *request) {
}
void Storage::requestFinishedCallback(Networking::Request *invalidRequestPointer) {
+ bool restartSync = false;
+
_runningRequestsMutex.lock();
if (invalidRequestPointer == _savesSyncRequest)
_savesSyncRequest = nullptr;
--_runningRequestsCount;
- if (_runningRequestsCount == 0) debug("Storage is not working now");
+ if (_syncRestartRequestsed) restartSync = true;
+ if (_runningRequestsCount == 0 && !restartSync) debug("Storage is not working now");
_runningRequestsMutex.unlock();
+
+ if (restartSync)
+ syncSaves(nullptr, nullptr);
}
Networking::Request *Storage::upload(Common::String remotePath, Common::String localPath, UploadCallback callback, Networking::ErrorCallback errorCallback) {
@@ -111,11 +117,13 @@ SavesSyncRequest *Storage::syncSaves(BoolCallback callback, Networking::ErrorCal
_runningRequestsMutex.lock();
if (_savesSyncRequest) {
warning("Storage::syncSaves: there is a sync in progress already");
+ _syncRestartRequestsed = true;
_runningRequestsMutex.unlock();
return _savesSyncRequest;
}
if (!errorCallback) errorCallback = getErrorPrintingCallback();
_savesSyncRequest = new SavesSyncRequest(this, callback, errorCallback);
+ _syncRestartRequestsed = false;
_runningRequestsMutex.unlock();
return (SavesSyncRequest *)addRequest(_savesSyncRequest); //who knows what that ConnMan could return in the future
}