Commit 2e37618
committed
fs: fix
82bdf8f fixed an issue by silently modifying the `start`
option for the case when only `end` is passed, in order to perform
reads from a specified range in the file.
However, that approach does not work for non-seekable files, since
a numeric `start` option means that positioned reads will be used
to read data from the file.
This patch fixes that, and instead ends reading after a specified
size by adjusting the read buffer size.
This way we avoid re-introducing the bug that 82bdf8f fixed,
and align behaviour with the native file stream mechanism
introduced in #18936 as well.
PR-URL: #19329
Fixes: #19240
Refs: #18121
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chen Gang <gangc.cxy@foxmail.com>createReadStream(…, {end: n}) for non-seekable fds1 parent 893432a commit 2e37618
2 files changed
+36
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1967 | 1967 | | |
1968 | 1968 | | |
1969 | 1969 | | |
1970 | | - | |
1971 | | - | |
| 1970 | + | |
1972 | 1971 | | |
1973 | 1972 | | |
1974 | 1973 | | |
| |||
1993 | 1992 | | |
1994 | 1993 | | |
1995 | 1994 | | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
1996 | 2001 | | |
1997 | 2002 | | |
1998 | 2003 | | |
| |||
2047 | 2052 | | |
2048 | 2053 | | |
2049 | 2054 | | |
| 2055 | + | |
| 2056 | + | |
2050 | 2057 | | |
2051 | 2058 | | |
2052 | 2059 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
181 | 208 | | |
182 | 209 | | |
183 | 210 | | |
| |||
0 commit comments