Last active
August 29, 2015 14:12
-
-
Save thejhh/c390acba36532eb2d3d4 to your computer and use it in GitHub Desktop.
Node.js sync file permissions not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * My system is Ubuntu Linux, so this is not Windows issue. | |
| * My Node.js is v0.10.35. | |
| * Async calls seems to work OK, this problem seems to exist only on synchronous calls. | |
| */ | |
| var fs = require('fs'); | |
| fs.writeFileSync("test.txt", "Hello World", { | |
| encoding:"utf8", | |
| mode:parseInt("0644",8) | |
| }); | |
| var f = fs.statSync("test.txt"); | |
| // Should be 33188 (100644) but is 33152 (100600) | |
| console.log(f.mode); | |
| console.log(f.mode.toString(8)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Modes as string are not working either. | |
| * | |
| * ------------------ | |
| * | |
| * My system is Ubuntu Linux, so this is not Windows issue. | |
| * My Node.js is v0.10.35. | |
| * Async calls seems to work OK, this problem seems to exist only on synchronous calls. | |
| */ | |
| var fs = require('fs'); | |
| fs.writeFileSync("test.txt", "Hello World", { | |
| encoding:"utf8", | |
| mode:"0644" | |
| }); | |
| var f = fs.statSync("test.txt"); | |
| // Should be 33188 (100644) but is 33152 (100600) | |
| console.log(f.mode); | |
| console.log(f.mode.toString(8)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment