Homebrew Store: Add support for cancelling downloads, fix progress bar. Fixes #9374

This commit is contained in:
Henrik Rydgård committed 2017-03-06 16:03:05 +01:00
1 parent 56e0d5ece2
commit 85c8d9b806
10 files changed
+82 -27

No files matched your search

+3 -1
View File
@@ -183,7 +183,7 @@ bool Buffer::ReadAll(int fd, int hintSize) {
return true;
}
bool Buffer::ReadAllWithProgress(int fd, int knownSize, float *progress) {
bool Buffer::ReadAllWithProgress(int fd, int knownSize, float *progress, bool *cancelled) {
std::vector<char> buf;
if (knownSize >= 65536 * 16) {
buf.resize(65536);
@@ -195,6 +195,8 @@ bool Buffer::ReadAllWithProgress(int fd, int knownSize, float *progress) {
int total = 0;
while (true) {
if (cancelled && *cancelled)
return false;
int retval = recv(fd, &buf[0], (int)buf.size(), 0);
if (retval == 0) {
return true;