diff options
author | Alexander Tkachev | 2016-06-19 13:50:11 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 4c381dafa3aff9feeb80e1be3272eba8ca73d442 (patch) | |
tree | 271949871b1a7ee77df6ad7f1b62cfb2a57922ee /backends/cloud | |
parent | 2d3cfffa84f80578dfc0bd3c72b83587f9b8dae5 (diff) | |
download | scummvm-rg350-4c381dafa3aff9feeb80e1be3272eba8ca73d442.tar.gz scummvm-rg350-4c381dafa3aff9feeb80e1be3272eba8ca73d442.tar.bz2 scummvm-rg350-4c381dafa3aff9feeb80e1be3272eba8ca73d442.zip |
CLOUD: Delete the incomplete file (when downloading)
Diffstat (limited to 'backends/cloud')
-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); } |