fix(dssnap): ensure idempotent write of empty chunks

This commit is contained in:
Andrew Mayorov 2024-04-19 18:52:33 +02:00
parent bac5100635
commit 43f8346c00
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
1 changed files with 3 additions and 1 deletions

View File

@ -267,7 +267,9 @@ new_writer_file(#writer{dirpath = DirPath}, RelPath) ->
write_chunk_file(WFile0 = #wfile{fd = IoDev, pos = Pos, abspath = AbsPath}, Pos, More, Chunk) ->
ChunkSize = byte_size(Chunk),
case file:write(IoDev, Chunk) of
case (ChunkSize > 0) andalso file:write(IoDev, Chunk) of
false ->
WFile0;
ok ->
WFile1 = WFile0#wfile{pos = Pos + ChunkSize},
case More of