Skip to content

Commit

Permalink
Add debug loggin for temp file cleaning up insted throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanBurunkov committed Apr 8, 2020
1 parent 85bf218 commit 5fb6150
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/tempFileHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = (options, fieldname, filename) => {
let writePromise = Promise.resolve();

const createWriteStream = () => {
debugLog(options, `Opening write stream for ${fieldname}->${filename}...`);
writeStream = fs.createWriteStream(tempFilePath);
writePromise = new Promise((resolve, reject) => {
writeStream.on('finish', () => {
Expand Down Expand Up @@ -62,7 +63,10 @@ module.exports = (options, fieldname, filename) => {
if (writeStream !== false) {
debugLog(options, `Cleaning up temporary file ${tempFilePath}...`);
writeStream.end();
deleteFile(tempFilePath, (err) => { if (err) throw err; });
deleteFile(tempFilePath, err => (err
? debugLog(options, `Cleaning up temporary file ${tempFilePath} failed: ${err}`)
: debugLog(options, `Cleaning up temporary file ${tempFilePath} done.`)
));
}
},
getWritePromise: () => writePromise
Expand Down

0 comments on commit 5fb6150

Please sign in to comment.