Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeFile, writeTextFile and renameRundown are unsafe #93

Open
Dan-Shields opened this issue Jan 23, 2024 · 1 comment
Open

writeFile, writeTextFile and renameRundown are unsafe #93

Dan-Shields opened this issue Jan 23, 2024 · 1 comment

Comments

@Dan-Shields
Copy link

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();
  }
})
@Dan-Shields Dan-Shields changed the title writeFile, writeTextFile and renameRundown, GetJsonData are unsafe writeFile, writeTextFile and renameRundown are unsafe Jan 23, 2024
@TuomoKu
Copy link
Owner

TuomoKu commented Nov 10, 2024

I will keep these here as a reminder for a future update. Thanks for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants