1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 12:41:15 +02:00

Merge branch 'master' of github.com:NixOS/nix into add-body-to-network-errors

This commit is contained in:
Carlo Nucera 2020-07-15 12:58:38 -04:00
commit 2d2a10e79a
48 changed files with 624 additions and 454 deletions

View file

@ -143,6 +143,7 @@ struct curlFileTransfer : public FileTransfer
LambdaSink finalSink;
std::shared_ptr<CompressionSink> decompressionSink;
std::optional<StringSink> errorSink;
std::exception_ptr writeException;
@ -159,12 +160,12 @@ struct curlFileTransfer : public FileTransfer
// the response around (which we figure won't be big
// like an actual download should be) to improve error
// messages.
decompressionSink = std::make_shared<TeeSink<ref<CompressionSink>>>(
ref<CompressionSink>{ decompressionSink }
);
errorSink = StringSink { };
}
}
if (errorSink)
(*errorSink)((unsigned char *) contents, realSize);
(*decompressionSink)((unsigned char *) contents, realSize);
return realSize;
@ -419,9 +420,8 @@ struct curlFileTransfer : public FileTransfer
attempt++;
std::shared_ptr<std::string> response;
if (decompressionSink)
if (auto teeSink = std::dynamic_pointer_cast<TeeSink<ref<CompressionSink>>>(decompressionSink))
response = teeSink->data;
if (errorSink)
response = errorSink->s;
auto exc =
code == CURLE_ABORTED_BY_CALLBACK && _isInterrupted
? FileTransferError(Interrupted, response, "%s of '%s' was interrupted", request.verb(), request.uri)