Skip to content

Folder permissions #11

@Epyon616

Description

@Epyon616

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions