Permalink
Browse files

consider Offset when computing truncation point

If Offset is ignored, the file will be truncated incorrectly after POST.
  • Loading branch information...
Bryan Fink
Bryan Fink committed Nov 29, 2011
1 parent 552ac5e commit b1b6cd181fee907392bcf1ee744a1796448a1c37
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/luwak_wm_file.erl
View
@@ -531,8 +531,8 @@ accept_streambody(RD, #ctx{handle={ok, H}, client=C, method=Method}) ->
{H2, Count} = accept_streambody1(Stream, 0, wrq:stream_req_body(RD, Size)),
H2Len = luwak_file:length(C, H2),
%% truncate will fail if passed a Start >= the length of the file
- if Count < H2Len ->
- {ok, _} = luwak_io:truncate(C, H2, Count),
+ if Offset+Count < H2Len ->
+ {ok, _} = luwak_io:truncate(C, H2, Offset+Count),
true;
true -> true
end.

0 comments on commit b1b6cd1

Please sign in to comment.