From 675773b92aea2d5c8fb1117d18d69e16944f6f64 Mon Sep 17 00:00:00 2001 From: Stephen Ward Date: Wed, 10 Oct 2018 15:10:34 -0400 Subject: [PATCH] re-added the newline, as well as another test case to make sure mode is still set to default value when a new file is opened --- src/filesystem/implementation.js | 1 + tests/spec/fs.open.spec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index c691d67..a6efc4b 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -1930,6 +1930,7 @@ function validateAndMaskMode(value, def, callback) { callback = def; def = undefined; } + if (isUint32(value)) { return value & FULL_READ_WRITE_EXEC_PERMISSIONS; } diff --git a/tests/spec/fs.open.spec.js b/tests/spec/fs.open.spec.js index ba76408..1907142 100644 --- a/tests/spec/fs.open.spec.js +++ b/tests/spec/fs.open.spec.js @@ -123,6 +123,22 @@ describe('fs.open', function() { }); }); + it('should create a new file, but no mode is passed, so the default value of 644 should be seen', function(done) { + + var fs = util.fs(); + fs.open('/myfile', 'w', function(error) { + if(error) throw error; + + fs.stat('/myfile', function(error, result) { + expect(error).not.to.exist; + expect(result).to.exist; + expect(result.mode).to.exist; + expect(result.mode & 0o644).to.equal(0o644); + done(); + }); + }); + }); + /** * This test is currently correct per our code, but incorrect according to the spec. * When we fix https://github.com/filerjs/filer/issues/314 we'll have to update this.