CLOUD: Delete the incomplete file (when downloading)
This commit is contained in:
parent
2d3cfffa84
commit
4c381dafa3
3 changed files with 23 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue