| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 55b0495 commit 2bda6db
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,12 +133,15 @@ async function* fileEntries(files, followSymlinks) { | |||
| 133 | 133 | // would let a symlink swapped in after the classification above redirect | |
| 134 | 134 | // the read - a TOCTOU that defeats followSymlinks:false. O_NOFOLLOW makes | |
| 135 | 135 | // a final-component symlink fail the open outright when not following; | |
| 136 | - // the fstat then confirms a regular file, never a FIFO, device, or | ||
| 137 | - // socket (which as a stream source could block or emit unbounded data). | ||
| 136 | + // O_NONBLOCK keeps the open itself from blocking on a FIFO or a slow | ||
| 137 | + // device (it has no effect on a regular file's reads), so the fstat can | ||
| 138 | + // then reject anything that is not a regular file - a FIFO, device, or | ||
| 139 | + // socket, which as a stream source could block or emit unbounded data. | ||
| 138 | 140 | // Metadata comes from that same fstat so it describes the inode we read. | |
| 139 | - const flags = followSymlinks ? | ||
| 141 | + const flags = (followSymlinks ? | ||
| 140 | 142 | fs.constants.O_RDONLY : | |
| 141 | - fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0); | ||
| 143 | + fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0)) | | ||
| 144 | + (fs.constants.O_NONBLOCK || 0); | ||
| 142 | 145 | const handle = await fs.promises.open(sourcePath, flags); | |
| 143 | 146 | let ownsHandle = true; | |
| 144 | 147 | try { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments