-
Notifications
You must be signed in to change notification settings - Fork 7.3k
File timestamp resolution is inconsistent with fs.stat / fs.utimes #7000
Comments
So there are a couple of things here, first in v0.10 the precision of The other issue you're having here, is that the interface for On the other hand, if you were to use var fs = require('fs');
fs.writeFileSync('test.txt', 'abc');
console.log(fs.statSync('test.txt').mtime.getTime());
var a = new Date(1356171132123);
var b = new Date(1356171132321);
fs.utimesSync('test.txt', a, b);
console.log(fs.statSync('test.txt').mtime.getTime());
var fd = fs.openSync('test.txt', 'r+');
fs.futimesSync(fd, a, b);
console.log(fs.statSync('test.txt').mtime.getTime());
Huge caveat being that this requires filesystems to support subsecond resolution, which not all do -- of note HFS, ext[2,3], FAT. |
As stated here: nodejs/node-v0.x-archive#7000 utimes has 1 second resolution, whereas futimes has 1 microsecond resolution. Since stat also has a 1 microsecond resolution, this caused conditional builds (with gulp-newer for instance) to always rebuild files on platforms with 1 microsecond timestamps for files (Linux with ext2/3).
Could the documentation (It only says Integer) be improved to make this clear? It looks like I can pass
Output
|
This repo is largely abandoned. If you have issues with Node core, please report them at https://github.com/nodejs/node. If you're looking for general support, please head to https://github.com/nodejs/help. |
In node 0.11.11 under windows 7
the file timestamp resolution of fs.stat seems to be 1 millisecond, but if i try to set the timestamps, the resolution seems to be only 1 second. This is inconsistent.
In node 0.10 the resolution seems to be always 1 second.
I think the resolution should be either 1 second or 1 millisecond, but not mixed.
The timestamp resolution of the underlying windows filesystem NTFS is 100 nanoseconds, so both solutions would be fine ;-)
The text was updated successfully, but these errors were encountered: