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

Folder permissions #11

Open
Epyon616 opened this issue Aug 13, 2018 · 0 comments
Open

Folder permissions #11

Epyon616 opened this issue Aug 13, 2018 · 0 comments

Comments

@Epyon616
Copy link

Epyon616 commented Aug 13, 2018

While trying to create a folder structure with file-system I noticed that there is something strange going on. While I can see that mkdir's -p option is implicit when creating a folder structure like this for instance: /storage/:userId/a/b/c/d with permissions 0o777. The permissions are only ever applied to directory d while the rest of the folder structure is set at the default (which I believe is 0o755) which is likely to cause issues when trying to save uploads as different files would be saved at different points along the directory path specified above.

The only way I have successfully managed to give all directories in the structure the same permissions so far is by adding each directory one at a time which is less than ideal. Below is an example of the code I have tried:

fs.mkdir(/storage/:userId/a/b/c/d, 0o777, (err) => { if (err) //some logging happens  } );

I have also tried using mkdirSync() and ended up with the same issue, in fact even when doing it one directory at a time mkdirSync() does not seem to set the permissions unless you call chmodSync() straight after.

At this stage I don't know if I am doing something wrong or if this is intended behaviour but its starting to frustrate me.

Could anyone shed any light on this?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant