File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -373,6 +373,27 @@ class GridstoreStorage {
373373 if ( streamOptions . end && streamOptions . end > attachmentData . length ) {
374374 streamOptions . end = attachmentData . length ;
375375 }
376+
377+ // Handle case where start equals or exceeds end
378+ if ( streamOptions . start && streamOptions . end && streamOptions . start >= streamOptions . end ) {
379+ streamOptions . start = attachmentData . length ;
380+ streamOptions . end = attachmentData . length ;
381+ }
382+
383+ // Handle case where start equals file length (EOF scenario)
384+ if ( streamOptions . start === attachmentData . length && ! streamOptions . end ) {
385+ streamOptions . end = attachmentData . length ;
386+ }
387+
388+ if ( streamOptions . end === null || streamOptions . end === undefined ) {
389+ // still no stream end, default to length
390+ streamOptions . end = attachmentData . length ;
391+ }
392+
393+ if ( streamOptions . start > streamOptions . end ) {
394+ // Ensure in any case that start is never bigger than end
395+ streamOptions . start = streamOptions . end ;
396+ }
376397 }
377398
378399 log . silly (
You can’t perform that action at this time.
0 commit comments