writeFile, writeTextFile and renameRundown are unsafe
Dan-Shields opened this issue · comments
Daniel Shields commented
All of these functions follow this pattern:
try {
return new Promise(resolve => {
// ... do stuff
resolve()
)
} catch (error) {
logger.error('spx.writeFile - Error while saving: ' + filepath + ': ' + error);
return
}
The try block will never fail, as the promise doesn't execute immediately
It should be:
return new Promise((resolve, reject) => {
try {
// ... do stuff
resolve();
} catch (error) {
logger.error('spx.duplicateFile - Error while duplicating: ' + fileRefe + ': ' + error);
reject();
}
})