diff options
-rw-r--r-- | backends/cloud/downloadrequest.cpp | 5 | ||||
-rw-r--r-- | backends/cloud/downloadrequest.h | 2 | ||||
-rw-r--r-- | backends/cloud/savessyncrequest.cpp | 17 |
3 files changed, 23 insertions, 1 deletions
diff --git a/backends/cloud/downloadrequest.cpp b/backends/cloud/downloadrequest.cpp index 307ea00aa2..497509b4a9 100644 --- a/backends/cloud/downloadrequest.cpp +++ b/backends/cloud/downloadrequest.cpp @@ -118,4 +118,9 @@ void DownloadRequest::finishSuccess(bool success) { if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); } +void DownloadRequest::finishError(Networking::ErrorResponse error) { + if (_localFile) _localFile->close(); + Request::finishError(error); +} + } // End of namespace Cloud diff --git a/backends/cloud/downloadrequest.h b/backends/cloud/downloadrequest.h index def69d47de..ff7820e3ee 100644 --- a/backends/cloud/downloadrequest.h +++ b/backends/cloud/downloadrequest.h @@ -43,6 +43,8 @@ class DownloadRequest: public Networking::Request { void streamCallback(Networking::NetworkReadStreamResponse response); void streamErrorCallback(Networking::ErrorResponse error); void finishSuccess(bool success); + virtual void finishError(Networking::ErrorResponse error); + public: DownloadRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb, Common::String remoteFileId, Common::DumpFile *dumpFile); virtual ~DownloadRequest(); diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp index 4d18647911..c43625315d 100644 --- a/backends/cloud/savessyncrequest.cpp +++ b/backends/cloud/savessyncrequest.cpp @@ -244,6 +244,8 @@ void SavesSyncRequest::fileDownloadedCallback(Storage::BoolResponse response) { //stop syncing if download failed if (!response.value) { + //delete the incomplete file + g_system->getSavefileManager()->removeSavefile(_currentDownloadingFile.name()); finishError(Networking::ErrorResponse(this, false, true, "", -1)); return; } @@ -342,7 +344,20 @@ Common::Array<Common::String> SavesSyncRequest::getFilesToDownload() { void SavesSyncRequest::finishError(Networking::ErrorResponse error) { debug("SavesSync::finishError"); - + //if we were downloading a file - remember the name + //and make the Request close() it, so we can delete it + Common::String name = _currentDownloadingFile.name(); + if (_workingRequest) { + _ignoreCallback = true; + _workingRequest->finish(); + _workingRequest = nullptr; + _ignoreCallback = false; + } + //unlock all the files by making getFilesToDownload() return empty array + _currentDownloadingFile = StorageFile(); + _filesToDownload.clear(); + //delete the incomplete file + if (name != "") g_system->getSavefileManager()->removeSavefile(name); Request::finishError(error); } |