Skip to content

Commit

Permalink
only throw when not file not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Feb 6, 2024
1 parent 418b9c8 commit ccea963
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ async function generateFileHash (filePath) {
try {
const fileBuffer = await fs.readFile(filePath)
return crypto.createHash('md5').update(fileBuffer).digest('hex').slice(0, 16)
} catch {
} catch (err) {
/* istanbul ignore next - we don't want to throw if a file wasn't found, just let Fastify return 404 for the original path */
if (err.code !== 'ENOENT') throw err
return ''
}
}
Expand Down

0 comments on commit ccea963

Please sign in to comment.