diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-10-13 14:34:45 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-10-13 14:34:45 -0600 |
commit | d51d85d49eb0429ba170c13de4ee8b4c277b7937 (patch) | |
tree | ed60233e128a6247b5cb029c75b564cf544d8c6b /src/net/download.cpp | |
parent | 6158b18c81ea5a32acd8bdecafe1dfe32619d667 (diff) | |
download | mana-d51d85d49eb0429ba170c13de4ee8b4c277b7937.tar.gz mana-d51d85d49eb0429ba170c13de4ee8b4c277b7937.tar.bz2 mana-d51d85d49eb0429ba170c13de4ee8b4c277b7937.tar.xz mana-d51d85d49eb0429ba170c13de4ee8b4c277b7937.zip |
Handle canceled downloads more gracefully
Diffstat (limited to 'src/net/download.cpp')
-rw-r--r-- | src/net/download.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp index 061cecfd..8a5e0828 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -215,6 +215,9 @@ int Download::downloadThread(void *ptr) { switch (res) { + case CURLE_ABORTED_BY_CALLBACK: + d->mOptions.cancel = true; + break; case CURLE_COULDNT_CONNECT: default: logger->log("curl error %d: %s host: %s", @@ -222,6 +225,11 @@ int Download::downloadThread(void *ptr) break; } + if (d->mOptions.cancel) + { + break; + } + d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_ERROR, 0, 0); if (!d->mOptions.memoryWrite) @@ -280,7 +288,11 @@ int Download::downloadThread(void *ptr) attempts++; } - if (!complete) { + if (d->mOptions.cancel) + { + // Nothing to do... + } + else if (!complete || attempts >= 3) { d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_ERROR, 0, 0); } else @@ -291,5 +303,4 @@ int Download::downloadThread(void *ptr) return 0; } - } // namespace Net |