File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -366,12 +366,23 @@ class GridstoreStorage {
366366 }
367367 }
368368
369- if ( streamOptions . start && streamOptions . start > attachmentData . length ) {
370- streamOptions . start = attachmentData . length ;
371- }
369+ streamOptions . start = Math . min (
370+ streamOptions . start ?? 0 , // Default to 0 if undefined/null
371+ attachmentData . length
372+ ) ;
372373
373- if ( streamOptions . end && streamOptions . end > attachmentData . length ) {
374+ streamOptions . end = Math . min (
375+ streamOptions . end ?? attachmentData . length , // Default to length if undefined/null
376+ attachmentData . length
377+ ) ;
378+
379+ if ( streamOptions . start >= attachmentData . length ) {
380+ // If start is at or beyond EOF, set both to EOF
381+ streamOptions . start = attachmentData . length ;
374382 streamOptions . end = attachmentData . length ;
383+ } else if ( streamOptions . start >= streamOptions . end ) {
384+ // If start >= end, clamp start to end (but not beyond file length)
385+ streamOptions . start = Math . min ( streamOptions . end , attachmentData . length ) ;
375386 }
376387 }
377388
You can’t perform that action at this time.
0 commit comments