Merge pull request #12901 from keynslug/fix/ds-snap-flaky-tc

fix(dssnap): ensure idempotent write of empty chunks
This commit is contained in:
Andrew Mayorov 2024-04-19 20:44:56 +02:00 committed by GitHub
commit ebc02cd39d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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) -> write_chunk_file(WFile0 = #wfile{fd = IoDev, pos = Pos, abspath = AbsPath}, Pos, More, Chunk) ->
ChunkSize = byte_size(Chunk), ChunkSize = byte_size(Chunk),
case file:write(IoDev, Chunk) of case (ChunkSize > 0) andalso file:write(IoDev, Chunk) of
false ->
WFile0;
ok -> ok ->
WFile1 = WFile0#wfile{pos = Pos + ChunkSize}, WFile1 = WFile0#wfile{pos = Pos + ChunkSize},
case More of case More of