File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -481,11 +481,12 @@ export abstract class File implements IDisposable {
481481 this . _fileStream . setLength ( this . _fileStream . length + bytesToAdd ) ;
482482
483483 // Step 3: Shuffle bytes to the end
484- const buffer = new Uint8Array ( File . bufferSize ) ;
484+ const _bufferSize = Math . min ( bytesToAdd , File . BUFFER_SIZE * 1024 ) ;
485+ const buffer = new Uint8Array ( _bufferSize ) ;
485486 const stopShufflingIndex = start + replace + bytesToAdd ;
486487 let shuffleIndex = this . _fileStream . length ;
487488 while ( shuffleIndex > stopShufflingIndex ) {
488- const bytesToReplace = Math . min ( shuffleIndex - stopShufflingIndex , File . bufferSize ) ;
489+ const bytesToReplace = Math . min ( shuffleIndex - stopShufflingIndex , _bufferSize ) ;
489490
490491 // Fill up the buffer
491492 this . _fileStream . seek ( shuffleIndex - bytesToReplace - bytesToAdd , SeekOrigin . Begin ) ;
You can’t perform that action at this time.
0 commit comments