Skip to content

Commit

Permalink
messages: fix EPERM error by verifying temp file removal when sending…
Browse files Browse the repository at this point in the history
… images (#1227)

* messages: add verification to remove temp file, solve EPERM operation not permitted

* fix lint on messages

* another try to fix lint for pr health

* Fixed, too many changes were breaking the code; this should be enough

* another try to fix this
  • Loading branch information
Iucasmaia authored Feb 2, 2025
1 parent 0d9c0e4 commit b78902f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ export const prepareWAMessageMedia = async(
encWriteStream.destroy()
// remove tmp files
if(didSaveToTmpPath && bodyPath) {
await fs.unlink(bodyPath)
logger?.debug('removed tmp files')
try {
await fs.access(bodyPath)
await fs.unlink(bodyPath)
logger?.debug('removed tmp file')
} catch(error) {
logger?.warn('failed to remove tmp file')
}
}
}
)
Expand Down

0 comments on commit b78902f

Please sign in to comment.