Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14cf22f

Browse filesBrowse files
richardlaurvagg
authored andcommitted
fs, src, lib: fix blksize & blocks on Windows
libuv returns values for `blksize` and `blocks` on stat calls so do not coerce them into `undefined` on Windows. PR-URL: #26056 Fixes: #25913 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2d0242a commit 14cf22f
Copy full SHA for 14cf22f

File tree

Expand file treeCollapse file tree

7 files changed

+10
-25
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+10
-25
lines changed
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+1-2Lines changed: 1 addition & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3414,8 +3414,7 @@ to compare `curr.mtime` and `prev.mtime`.
34143414

34153415
When an `fs.watchFile` operation results in an `ENOENT` error, it
34163416
will invoke the listener once, with all the fields zeroed (or, for dates, the
3417-
Unix Epoch). In Windows, `blksize` and `blocks` fields will be `undefined`,
3418-
instead of zero. If the file is created later on, the listener will be called
3417+
Unix Epoch). If the file is created later on, the listener will be called
34193418
again, with the latest stat objects. This is a change in functionality since
34203419
v0.10.
34213420

Collapse file

‎lib/internal/fs/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/utils.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ Stats.prototype.isSocket = function() {
315315
function getStatsFromBinding(stats, offset = 0) {
316316
return new Stats(stats[0 + offset], stats[1 + offset], stats[2 + offset],
317317
stats[3 + offset], stats[4 + offset], stats[5 + offset],
318-
isWindows ? undefined : stats[6 + offset], // blksize
318+
stats[6 + offset], // blksize
319319
stats[7 + offset], stats[8 + offset],
320-
isWindows ? undefined : stats[9 + offset], // blocks
320+
stats[9 + offset], // blocks
321321
stats[10 + offset], stats[11 + offset],
322322
stats[12 + offset], stats[13 + offset]);
323323
}
Collapse file

‎src/node_file.h‎

Copy file name to clipboardExpand all lines: src/node_file.h
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,10 @@ constexpr void FillStatsArray(AliasedBuffer<NativeT, V8T>* fields,
199199
fields->SetValue(offset + 3, s->st_uid);
200200
fields->SetValue(offset + 4, s->st_gid);
201201
fields->SetValue(offset + 5, s->st_rdev);
202-
#if defined(__POSIX__)
203202
fields->SetValue(offset + 6, s->st_blksize);
204-
#else
205-
fields->SetValue(offset + 6, 0);
206-
#endif
207203
fields->SetValue(offset + 7, s->st_ino);
208204
fields->SetValue(offset + 8, s->st_size);
209-
#if defined(__POSIX__)
210205
fields->SetValue(offset + 9, s->st_blocks);
211-
#else
212-
fields->SetValue(offset + 9, 0);
213-
#endif
214206
// Dates.
215207
fields->SetValue(offset + 10, ToNative<NativeT>(s->st_atim));
216208
fields->SetValue(offset + 11, ToNative<NativeT>(s->st_mtim));
Collapse file

‎test/parallel/test-fs-stat-bigint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-stat-bigint.js
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ function verifyStats(bigintStats, numStats) {
5959
bigintStats.isSymbolicLink(),
6060
numStats.isSymbolicLink()
6161
);
62-
} else if (common.isWindows && (key === 'blksize' || key === 'blocks')) {
63-
assert.strictEqual(bigintStats[key], undefined);
64-
assert.strictEqual(numStats[key], undefined);
6562
} else if (Number.isSafeInteger(val)) {
6663
assert.strictEqual(
6764
bigintStats[key], BigInt(val),
Collapse file

‎test/parallel/test-fs-stat.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-stat.js
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ fs.stat(__filename, common.mustCall(function(err, s) {
9494
assert.strictEqual(s.isSymbolicLink(), false);
9595
const keys = [
9696
'dev', 'mode', 'nlink', 'uid',
97-
'gid', 'rdev', 'ino', 'size',
97+
'gid', 'rdev', 'blksize', 'ino', 'size', 'blocks',
9898
'atime', 'mtime', 'ctime', 'birthtime',
9999
'atimeMs', 'mtimeMs', 'ctimeMs', 'birthtimeMs'
100100
];
101-
if (!common.isWindows) {
102-
keys.push('blocks', 'blksize');
103-
}
104101
const numberFields = [
105-
'dev', 'mode', 'nlink', 'uid', 'gid', 'rdev', 'ino', 'size',
106-
'atimeMs', 'mtimeMs', 'ctimeMs', 'birthtimeMs'
102+
'dev', 'mode', 'nlink', 'uid', 'gid', 'rdev', 'blksize', 'ino', 'size',
103+
'blocks', 'atimeMs', 'mtimeMs', 'ctimeMs', 'birthtimeMs'
107104
];
108105
const dateFields = ['atime', 'mtime', 'ctime', 'birthtime'];
109106
keys.forEach(function(k) {
Collapse file

‎test/parallel/test-fs-watchfile-bigint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watchfile-bigint.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const expectedStatObject = new fs.Stats(
1515
0n, // uid
1616
0n, // gid
1717
0n, // rdev
18-
common.isWindows ? undefined : 0n, // blksize
18+
0n, // blksize
1919
0n, // ino
2020
0n, // size
21-
common.isWindows ? undefined : 0n, // blocks
21+
0n, // blocks
2222
0n, // atim_msec
2323
0n, // mtim_msec
2424
0n, // ctim_msec
Collapse file

‎test/parallel/test-fs-watchfile.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watchfile.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ const expectedStatObject = new fs.Stats(
3838
0, // uid
3939
0, // gid
4040
0, // rdev
41-
common.isWindows ? undefined : 0, // blksize
41+
0, // blksize
4242
0, // ino
4343
0, // size
44-
common.isWindows ? undefined : 0, // blocks
44+
0, // blocks
4545
Date.UTC(1970, 0, 1, 0, 0, 0), // atime
4646
Date.UTC(1970, 0, 1, 0, 0, 0), // mtime
4747
Date.UTC(1970, 0, 1, 0, 0, 0), // ctime

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.