diff options
author | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-07-15 12:58:38 -0400 |
---|---|---|
committer | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-07-15 13:06:08 -0400 |
commit | 2d2a10e79a3abb5eb2ae271f5ff1ca14b3ae6cad (patch) | |
tree | df0e14e1d5035215df034a77506ead1d839caf3b /src/libstore/filetransfer.cc | |
parent | 465daa9396a0e4203fb8f575da219ea79c5fefa8 (diff) | |
parent | cff2157185912025c24a1b9dc99056161634176c (diff) |
Merge branch 'master' of github.com:NixOS/nix into add-body-to-network-errors
Diffstat (limited to 'src/libstore/filetransfer.cc')
-rw-r--r-- | src/libstore/filetransfer.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 8b66cbdad..f27222441 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -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) |