fs: consider NaN/Infinity in toUnixTimestamp#2387
fs: consider NaN/Infinity in toUnixTimestamp#2387yorkie wants to merge 1 commit intonodejs:masterfrom
Conversation
|
Why not replace both checks with |
|
Oh, I absolutely this function, let me use and test it, thanks for the tip |
|
Fixed, thank you Brian |
|
I meant replace both conditions, like simply: if (!isFinite(time)) {since |
|
Fixed, thank you |
test/parallel/test-fs-utimes.js
Outdated
There was a problem hiding this comment.
What exactly to do here?
There was a problem hiding this comment.
Sorry, it should be "done"
|
Corrected, thanks @thefourtheye |
lib/fs.js
Outdated
There was a problem hiding this comment.
Should use Number.isFinite() instead of isFinite():
In comparison to the global isFinite() function, this method doesn't forcibly convert the parameter to a number. This means only values of the type number, that are also finite, return true.
Doesn't matter here, but good for consistency.
|
After reading some docs about the difference at MDN and ECMA spec, I changed it to use the |
|
Any feedback from core team? |
|
LGTM |
|
Hmmm.
|
I have no idea about the negative, because the linux manual didn't mention this, so I have the following proposals:
I will document this either after getting the answer of the above from @thefourtheye or other Node.js team member. Thank you :) |
|
any words? @thefourtheye |
|
How is this pr going? @thefourtheye did ignore my questions and proposals again, I don't know what happened :( |
|
@yorkie Might be outside the scope of this PR, but is there utility in accepting strings? The check would basically be: if (typeof time === 'string' && +time == time) {
return +time;
}I'm cool w/ the change if CI is happy. |
|
Hey @trevnorris I Added your suggestion at this PR, but I still care about strict mode and source code confusion in using the operator Mainly, the unit test is pass on my side :) |
|
Added few document as well, but I have not yet got any response about minus value, so I will just keep the current logic. |
|
@yorkie I am really sorry about the delay. I finally got some time to test this. The value of |
doc/api/fs.markdown
Outdated
|
It's fine @thefourtheye
Do you have some document about this or someone from nodejs team tell me what should I do, or I think set to Unix Epoch is not still the best solution. |
|
@yorkie Thanks. Only reason I suggest using |
|
@yorkie I searched for documentations but I couldn't find any. I found that by running const fs = require('fs');
console.error(fs.statSync('Test.py'));
fs.utimesSync('Test.py', -1, -1);
console.error(fs.statSync('Test.py')); |
|
Thanks for your work @thefourtheye, I will follow your running result at first :) |
|
Updated, now the minus number and other |
|
@yorkie Ah, lets get some confirmation about the negative values. @bnoordhuis any idea? |
|
Of course, and I will document something after that :) |
|
Ping @bnoordhuis |
|
@orangemocha so the thing that I should or can do is reword the title and push again? |
test/parallel/test-fs-utimes.js
Outdated
There was a problem hiding this comment.
Linter would break at this line? @Fishrock123
@yorke : yes! |
|
Yes, sir. I will fix the line 131 as well :) |
|
@yorkie : or, if you added those tests in the first place, you could also do an interactive rebase and change your commits to simply not add them. |
|
Ok, I did squash all commits then could someone run the CI again, thanks for your helps :) |
|
The test seems to be suspended by ARM at https://ci.nodejs.org/job/node-test-commit-arm/634/console, anything that I can help to fix? |
|
@yorkie Just took a really long time to finish. Everything looks green now. |
PR-URL: #2387 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
|
Landed on 1f842c2 with column change in doc. |
|
To clarify, this is indeed a breaking change? |
|
Thanks @trevnorris
Shouldn't, I guess few modules use |
|
@Fishrock123 I'd say this is a bug-fix. This simply makes previously undefined behavior defined. |
PR-URL: #2387 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Notable changes: * buffer: - Buffers are now created in JavaScript, rather than C++. This increases the speed of buffer creation (Trevor Norris) nodejs#2866. - `Buffer#slice()` now uses `Uint8Array#subarray()` internally, increasing `slice()` performance (Karl Skomski) nodejs#2777. * fs: - `fs.utimes()` now properly converts numeric strings, `NaN`, and `Infinity` (Yazhong Liu) nodejs#2387. - `fs.WriteStream` now implements `_writev`, allowing for super-fast bulk writes (Ron Korving) nodejs#2167. * http: Fixed an issue with certain `write()` sizes causing errors when using `http.request()` (Fedor Indutny) nodejs#2824. * npm: Upgrade to version 2.14.3, see https://github.com/npm/npm/releases/tag/v2.14.3 for more details (Kat Marchán) nodejs#2822. * src: V8 cpu profiling no longer erroneously shows idle time (Oleksandr Chekhovskyi) nodejs#2324. * v8: Lateral upgrade to 4.5.103.33 from 4.5.103.30, contains minor fixes (Ali Ijaz Sheikh) nodejs#2870. - This fixes a previously known bug where some computed object shorthand properties did not work correctly (nodejs#2507). Refs: nodejs#2844 PR-URL: nodejs#2889
Notable changes: * buffer: - Buffers are now created in JavaScript, rather than C++. This increases the speed of buffer creation (Trevor Norris) #2866. - `Buffer#slice()` now uses `Uint8Array#subarray()` internally, increasing `slice()` performance (Karl Skomski) #2777. * fs: - `fs.utimes()` now properly converts numeric strings, `NaN`, and `Infinity` (Yazhong Liu) #2387. - `fs.WriteStream` now implements `_writev`, allowing for super-fast bulk writes (Ron Korving) #2167. * http: Fixed an issue with certain `write()` sizes causing errors when using `http.request()` (Fedor Indutny) #2824. * npm: Upgrade to version 2.14.3, see https://github.com/npm/npm/releases/tag/v2.14.3 for more details (Kat Marchán) #2822. * src: V8 cpu profiling no longer erroneously shows idle time (Oleksandr Chekhovskyi) #2324. * v8: Lateral upgrade to 4.5.103.33 from 4.5.103.30, contains minor fixes (Ali Ijaz Sheikh) #2870. - This fixes a previously known bug where some computed object shorthand properties did not work correctly (#2507). Refs: #2844 PR-URL: #2889
We might should follow the rule of linux:
ref: http://linux.die.net/man/2/utime