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
878
878
Err ( e) => return Err ( e) ,
879
879
} ;
880
880
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 {
884
886
debug ! ( "Reading for partial block write" ) ;
885
887
data. block_cache
886
888
. read_mut ( block_idx)
887
889
. map_err ( Error :: DeviceError ) ?
888
- } else {
889
- data. block_cache . blank_mut ( block_idx)
890
890
} ;
891
891
block[ block_offset..block_offset + to_copy]
892
892
. copy_from_slice ( & buffer[ written..written + to_copy] ) ;
You can’t perform that action at this time.
0 commit comments