Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: fix type of atime/mtime #29666

Closed
wants to merge 3 commits into from
Closed

doc: fix type of atime/mtime #29666

wants to merge 3 commits into from

Conversation

exoego
Copy link
Contributor

@exoego exoego commented Sep 23, 2019

It seems that fs.unlinkSync and fs.utimesSync can accept number, Date or string as same as fs.unlink and fs.utimes.

node/lib/fs.js

Lines 1177 to 1196 in 3a2e75d

function utimes(path, atime, mtime, callback) {
callback = makeCallback(callback);
path = getValidatedPath(path);
const req = new FSReqCallback();
req.oncomplete = callback;
binding.utimes(pathModule.toNamespacedPath(path),
toUnixTimestamp(atime),
toUnixTimestamp(mtime),
req);
}
function utimesSync(path, atime, mtime) {
path = getValidatedPath(path);
const ctx = { path };
binding.utimes(pathModule.toNamespacedPath(path),
toUnixTimestamp(atime), toUnixTimestamp(mtime),
undefined, ctx);
handleErrorFromBinding(ctx);
}

node/lib/fs.js

Lines 1189 to 1206 in 3a2e75d

function utimesSync(path, atime, mtime) {
path = getValidatedPath(path);
const ctx = { path };
binding.utimes(pathModule.toNamespacedPath(path),
toUnixTimestamp(atime), toUnixTimestamp(mtime),
undefined, ctx);
handleErrorFromBinding(ctx);
}
function futimes(fd, atime, mtime, callback) {
validateInt32(fd, 'fd', 0);
atime = toUnixTimestamp(atime, 'atime');
mtime = toUnixTimestamp(mtime, 'mtime');
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.futimes(fd, atime, mtime, req);
}

Checklist

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Sep 23, 2019
* `atime` {integer}
* `mtime` {integer}
* `atime` {number|string|Date}
* `mtime` {number|string|Date}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be best to keep integer instead of number. We might want to have a stricter validation here at some point. I am not sure what the behavior would be in case a decimal is used instead of an integer.

Copy link
Contributor Author

@exoego exoego Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there is no validation nor rounding, so decimal will be used as decimal.

if (Number.isFinite(time)) {
if (time < 0) {
return Date.now() / 1000;
}
return time;
}

Are these supposed to be integer?
Updated so in 019b628

Copy link
Member

@lpinca lpinca Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I think number is more appropriate. Sorry for the trouble.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 22157ef

@Trott
Copy link
Member

Trott commented Oct 1, 2019

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 1, 2019
@Trott
Copy link
Member

Trott commented Oct 1, 2019

Landed in 16e47b9

@Trott Trott closed this Oct 1, 2019
Trott pushed a commit that referenced this pull request Oct 1, 2019
PR-URL: #29666
Reviewed-By: Luigi Pinca <[email protected]>
@exoego exoego deleted the patch-1 branch October 1, 2019 05:05
targos pushed a commit that referenced this pull request Oct 1, 2019
PR-URL: #29666
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants