diff options
author | Alexander Tkachev | 2016-06-13 12:32:33 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 0aea8db7e1a59e8cf88436f78019685c9aff6332 (patch) | |
tree | f1ffcc4e152a7f0dde1481a1d1b46ceded5cfab8 /backends/cloud | |
parent | ca0b58513d572419c52ba28ca09f4a086c543893 (diff) | |
download | scummvm-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')
-rw-r--r-- | backends/cloud/storage.cpp | 10 | ||||
-rw-r--r-- | backends/cloud/storage.h | 1 |
2 files changed, 10 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 } diff --git a/backends/cloud/storage.h b/backends/cloud/storage.h index a76f2169bc..ace2f30864 100644 --- a/backends/cloud/storage.h +++ b/backends/cloud/storage.h @@ -62,6 +62,7 @@ protected: uint32 _runningRequestsCount; Common::Mutex _runningRequestsMutex; SavesSyncRequest *_savesSyncRequest; + bool _syncRestartRequestsed; /** Returns default error callback (printErrorResponse). */ virtual Networking::ErrorCallback getErrorPrintingCallback(); |