Skip to content

Commit

Permalink
Fix multipart failures
Browse files Browse the repository at this point in the history
multipart files didn't ensure directories existed, which caused failures
in nested directory structures.

Additionally, when crashing, multipart error messages weren't truncated
and nodes could use a lot of memory.
  • Loading branch information
ferd committed Jul 29, 2024
1 parent 816af8f commit 64bf823
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/revault/src/revault_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,9 @@ format_status(Status) ->
format_status_msg({info, {revault, Marker, {file, F, Meta, Bin}}}) when byte_size(Bin) > 64 ->
BinSize = integer_to_binary(byte_size(Bin)),
{revault, Marker, {file, F, Meta, <<"[truncated: ", BinSize/binary, " bytes]">>}};
format_status_msg({info, {revault, Marker, {file, F, Meta, PartNum, PartTotal, Bin}}}) when byte_size(Bin) > 64 ->
BinSize = integer_to_binary(byte_size(Bin)),
{revault, Marker, {file, F, Meta, PartNum, PartTotal, <<"[truncated: ", BinSize/binary, " bytes]">>}};
format_status_msg(Term) -> Term.

%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -1137,6 +1140,7 @@ handle_multipart_file(MPState, F, Hash, PartNum, PartTotal, Bin) when PartNum ==
%% use an unpredictable rand file since this may be one of many incidentally
%% conflicting files sharing the same name, even if unlikely. Better to protect
%% against overlapping runs.
ok = revault_file:ensure_dir(F),
State = revault_file:multipart_init(F, PartTotal, Hash),
{ok, NewState} = revault_file:multipart_update(State, F, PartNum, PartTotal, Hash, Bin),
{new, MPState#{F => NewState}};
Expand Down

0 comments on commit 64bf823

Please sign in to comment.