Problem solved! It's actually the original problem - the patch I submitted was misapplied. The problem is in couch_rep - this code:

write_streamed_attachment(Stream, F, LenLeft) ->
    Bin = F(),
    ok = couch_stream:write(Stream, check_bin_length(LenLeft, Bin)),
    write_streamed_attachment(Stream, F, LenLeft - size(Bin)).

needs to be this:

write_streamed_attachment(Stream, F, LenLeft) ->
    Bin = F(),
    TruncatedBin = check_bin_length(LenLeft, Bin),
    ok = couch_stream:write(Stream, TruncatedBin),
    write_streamed_attachment(Stream, F, LenLeft - size(TruncatedBin)).

The problem is the last parameter to write_streamed_attachment being < 0 when the data is too long.

Antony Blakey
--------------------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

Always have a vision. Why spend your life making other people’s dreams?
 -- Orson Welles (1915-1985)

Reply via email to