Skip to content

Instantly share code, notes, and snippets.

@thejhh
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save thejhh/c390acba36532eb2d3d4 to your computer and use it in GitHub Desktop.

Select an option

Save thejhh/c390acba36532eb2d3d4 to your computer and use it in GitHub Desktop.
Node.js sync file permissions not working
/*
* 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));
/*
* 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