aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlo Nucera <carlo.nucera@protonmail.com>2020-06-17 11:16:16 -0400
committerCarlo Nucera <carlo.nucera@protonmail.com>2020-06-17 11:16:16 -0400
commit079c6e87deb100bf21f35150736f9662557e698e (patch)
tree0cb0efe121d7dd2251162fbe5eb940c33663ced8 /src
parentccbea8255cf52413938d994a69222fd953b08659 (diff)
Make successful states coherent
The successful states used in these two places in the code were slightly different. Should they be the same list?
Diffstat (limited to 'src')
-rw-r--r--src/libstore/filetransfer.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index c954ace7f..081960912 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -72,6 +72,8 @@ struct curlFileTransfer : public FileTransfer
curl_off_t writtenToSink = 0;
+ inline static const std::set<long> successfulStatuses;
+
/* Get the HTTP status code, or 0 for other protocols. */
long getHTTPStatus()
{
@@ -98,7 +100,7 @@ struct curlFileTransfer : public FileTransfer
/* Only write data to the sink if this is a
successful response. */
- if (httpStatus == 0 || httpStatus == 200 || httpStatus == 201 || httpStatus == 206) {
+ if (successfulStatuses.find(httpStatus) != successfulStatuses.end()) {
writtenToSink += len;
this->request.dataCallback((char *) data, len);
}
@@ -352,8 +354,7 @@ struct curlFileTransfer : public FileTransfer
if (writeException)
failEx(writeException);
- else if (code == CURLE_OK &&
- (httpStatus == 200 || httpStatus == 201 || httpStatus == 204 || httpStatus == 206 || httpStatus == 304 || httpStatus == 0 /* other protocol */))
+ else if (code == CURLE_OK && successfulStatuses.find(httpStatus) != successfulStatuses.end())
{
result.cached = httpStatus == 304;
act.progress(result.bodySize, result.bodySize);