diff options
author | Alexander Tkachev | 2016-07-14 14:55:03 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | d863dad055acbc066d86f7fbfa054e7f4c2dd7b2 (patch) | |
tree | d5ce5e282bd5b81160af75c5afd320a411c00bef | |
parent | cdf8ab7949b93f30522ea2742eb4cea3cfcec778 (diff) | |
download | scummvm-rg350-d863dad055acbc066d86f7fbfa054e7f4c2dd7b2.tar.gz scummvm-rg350-d863dad055acbc066d86f7fbfa054e7f4c2dd7b2.tar.bz2 scummvm-rg350-d863dad055acbc066d86f7fbfa054e7f4c2dd7b2.zip |
CLOUD: Fix FolderDownloadRequest::getProgress()
Now it doesn't stop on 100 % on last file and it ignores the
directories, so it doesn't "jump" suddenly as there are no directories
to skip.
-rw-r--r-- | backends/cloud/folderdownloadrequest.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/backends/cloud/folderdownloadrequest.cpp b/backends/cloud/folderdownloadrequest.cpp index 1d42f27d3f..c77fc27b35 100644 --- a/backends/cloud/folderdownloadrequest.cpp +++ b/backends/cloud/folderdownloadrequest.cpp @@ -65,6 +65,14 @@ void FolderDownloadRequest::directoryListedCallback(Storage::ListDirectoryRespon _workingRequest = nullptr; if (_ignoreCallback) return; _pendingFiles = response.value; + + // remove all directories + for (Common::Array<StorageFile>::iterator i = _pendingFiles.begin(); i != _pendingFiles.end(); ) + if (i->isDirectory()) + _pendingFiles.erase(i); + else + ++i; + _totalFiles = _pendingFiles.size(); downloadNextFile(); } @@ -146,7 +154,8 @@ double FolderDownloadRequest::getProgress() const { if (idDownloadRequest != nullptr) currentFileProgress = idDownloadRequest->getProgress(); } - return (double)(_totalFiles - _pendingFiles.size() + currentFileProgress) / (double)(_totalFiles); + uint32 uploadedFiles = _totalFiles - _pendingFiles.size() - 1; // -1 because currently downloaded file is already removed from _pendingFiles + return (double)(uploadedFiles + currentFileProgress) / (double)(_totalFiles); } } // End of namespace Cloud |