File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -878,15 +878,15 @@ where
878878 Err ( e) => return Err ( e) ,
879879 } ;
880880 let to_copy = core:: cmp:: min ( block_avail, bytes_to_write - written) ;
881- let block = if block_offset != 0
882- || data. open_files [ file_idx] . current_offset < data. open_files [ file_idx] . entry . size
883- {
881+ let block = if ( block_offset == 0 ) && ( to_copy == block_avail) {
882+ // we're replacing the whole Block, so the previous contents
883+ // are irrelevant
884+ data. block_cache . blank_mut ( block_idx)
885+ } else {
884886 debug ! ( "Reading for partial block write" ) ;
885887 data. block_cache
886888 . read_mut ( block_idx)
887889 . map_err ( Error :: DeviceError ) ?
888- } else {
889- data. block_cache . blank_mut ( block_idx)
890890 } ;
891891 block[ block_offset..block_offset + to_copy]
892892 . copy_from_slice ( & buffer[ written..written + to_copy] ) ;
You can’t perform that action at this time.
0 commit comments