Fix S3BinaryCacheStore
It failed with
AWS error uploading ‘6gaxphsyhg66mz0a00qghf9nqf7majs2.ls.xz’: Unable to parse ExceptionName: MissingContentLength Message: You must provide the Content-Length HTTP header.
possibly because the istringstream_nocopy introduced in
0d2ebb4373
doesn't supply the seek
method that the AWS library expects. So bring back the old version,
but only for S3BinaryCacheStore.
This commit is contained in:
parent
8df1a3b579
commit
e6a61b8da7
|
@ -155,7 +155,7 @@ static StringSet parseStrings(std::istream & str, bool arePaths)
|
||||||
static Derivation parseDerivation(const string & s)
|
static Derivation parseDerivation(const string & s)
|
||||||
{
|
{
|
||||||
Derivation drv;
|
Derivation drv;
|
||||||
istringstream_nocopy str(s);
|
std::istringstream str(s);
|
||||||
expect(str, "Derive([");
|
expect(str, "Derive([");
|
||||||
|
|
||||||
/* Parse the list of outputs. */
|
/* Parse the list of outputs. */
|
||||||
|
|
|
@ -18,6 +18,15 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
struct istringstream_nocopy : public std::stringstream
|
||||||
|
{
|
||||||
|
istringstream_nocopy(const std::string & s)
|
||||||
|
{
|
||||||
|
rdbuf()->pubsetbuf(
|
||||||
|
(char *) s.data(), s.size());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct S3Error : public Error
|
struct S3Error : public Error
|
||||||
{
|
{
|
||||||
Aws::S3::S3Errors err;
|
Aws::S3::S3Errors err;
|
||||||
|
|
|
@ -106,7 +106,7 @@ Hash parseHash(HashType ht, const string & s)
|
||||||
string s2(s, i * 2, 2);
|
string s2(s, i * 2, 2);
|
||||||
if (!isxdigit(s2[0]) || !isxdigit(s2[1]))
|
if (!isxdigit(s2[0]) || !isxdigit(s2[1]))
|
||||||
throw BadHash(format("invalid hash ‘%1%’") % s);
|
throw BadHash(format("invalid hash ‘%1%’") % s);
|
||||||
istringstream_nocopy str(s2);
|
std::istringstream str(s2);
|
||||||
int n;
|
int n;
|
||||||
str >> std::hex >> n;
|
str >> std::hex >> n;
|
||||||
hash.hash[i] = n;
|
hash.hash[i] = n;
|
||||||
|
|
|
@ -431,55 +431,4 @@ void callSuccess(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* A variant of std::istringstream that doesn't copy its string
|
|
||||||
argument. This is useful for large strings. The caller must ensure
|
|
||||||
that the string object is not destroyed while it's referenced by
|
|
||||||
this object. */
|
|
||||||
class istringbuf_nocopy : public std::streambuf
|
|
||||||
{
|
|
||||||
const std::string & s;
|
|
||||||
decltype(s.size()) off;
|
|
||||||
decltype(s.size()) size;
|
|
||||||
public:
|
|
||||||
istringbuf_nocopy(const std::string & s) : s{s}, off{0}, size{s.size()}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int_type underflow()
|
|
||||||
{
|
|
||||||
if (off == size)
|
|
||||||
return traits_type::eof();
|
|
||||||
return traits_type::to_int_type(s[off]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int_type uflow()
|
|
||||||
{
|
|
||||||
if (off == size)
|
|
||||||
return traits_type::eof();
|
|
||||||
return traits_type::to_int_type(s[off++]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int_type pbackfail(int_type ch)
|
|
||||||
{
|
|
||||||
if (off == 0 || (ch != traits_type::eof() && ch != s[off - 1]))
|
|
||||||
return traits_type::eof();
|
|
||||||
|
|
||||||
return traits_type::to_int_type(s[--off]);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::streamsize showmanyc()
|
|
||||||
{
|
|
||||||
return size - off;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct istringstream_nocopy : public std::iostream
|
|
||||||
{
|
|
||||||
istringbuf_nocopy buf;
|
|
||||||
istringstream_nocopy(const std::string & s) : std::iostream(&buf), buf(s) {};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue