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

b/c of umask, the default mode for ensureDir is 0777 & (~process.umask()) #651

Closed
qiulang opened this issue Nov 26, 2018 · 4 comments
Closed

Comments

@qiulang
Copy link

qiulang commented Nov 26, 2018

Because of umask, calling ensureDir/ensureDirSync without fs.chmodSync, the actual mode is not the same as the intended mode. I think it is better to mention this in https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md especially for someone who is not familiar with umask.

Besides, I feel it is unnecessary to call this in mkdirs.js because node will take care of that.

  if (mode === undefined) {
    mode = o777 & (~process.umask())
  }

Refer to

  1. Using fs.mkdir() make a directory according the Docs the argument 'mode' defaults to 0o777, but actually it's not. nodejs/node#15092
  2. https://stackoverflow.com/questions/30815154/fs-mkdir-is-creating-the-directory-with-different-permissions-than-those-speci
@RyanZim
Copy link
Collaborator

RyanZim commented May 21, 2019

PR welcome to clarify the docs. Thanks for the tip about explicitly doing it in the code, need to look into that.

@zensabbah
Copy link

A simple explanation of mode = 0o2775? Should it be chmod 775?

@RyanZim
Copy link
Collaborator

RyanZim commented Jun 3, 2020

Explicit code usage fixed in #791. Still needs documented; will try to get that done.

@RyanZim RyanZim self-assigned this Jun 3, 2020
@RyanZim
Copy link
Collaborator

RyanZim commented Jun 3, 2020

Actually, was under the impression Node has a note about this; since they don't, not a priority to do it here.

@RyanZim RyanZim closed this as completed Jun 3, 2020
@RyanZim RyanZim removed their assignment Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants