Skip to content

Commit

Permalink
fix(file): Unable to restrict the log file permissions, fixes #430
Browse files Browse the repository at this point in the history
  • Loading branch information
megahertz committed Jul 24, 2024
1 parent 38ad749 commit 80f8f63
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/node/transports/file/FileRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FileRegistry extends EventEmitter {
* @param {boolean} [writeAsync]
* @return {File}
*/
provide({ filePath, writeOptions, writeAsync = false }) {
provide({ filePath, writeOptions = {}, writeAsync = false }) {
let file;
try {
filePath = path.resolve(filePath);
Expand Down Expand Up @@ -49,7 +49,7 @@ class FileRegistry extends EventEmitter {
* @private
*/
createFile({ filePath, writeOptions, writeAsync }) {
this.testFileWriting(filePath);
this.testFileWriting({ filePath, writeOptions });
return new File({ path: filePath, writeOptions, writeAsync });
}

Expand All @@ -64,11 +64,12 @@ class FileRegistry extends EventEmitter {

/**
* @param {string} filePath
* @param {WriteOptions} writeOptions
* @private
*/
testFileWriting(filePath) {
testFileWriting({ filePath, writeOptions }) {
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, '', { flag: 'a' });
fs.writeFileSync(filePath, '', { flag: 'a', mode: writeOptions.mode });
}
}

Expand Down

0 comments on commit 80f8f63

Please sign in to comment.