Skip to content

Commit

Permalink
Merge pull request #1867 from hackmdio/refactor/reuse-random-filename
Browse files Browse the repository at this point in the history
refactor: reuse random filename in filesystem image provider
  • Loading branch information
Yukaii authored Jun 5, 2024
2 parents f8cfe81 + 5eb3591 commit a0c82d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/imageRouter/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function randomFilename () {
*/
function pickFilename (defaultFilename) {
let retryCounter = 5
let filename = defaultFilename
const extname = path.extname(defaultFilename)
let filename = `${randomFilename()}${extname}`
while (retryCounter-- > 0) {
if (fs.existsSync(path.join(config.uploadsPath, filename))) {
filename = `${randomFilename()}${extname}`
Expand Down

0 comments on commit a0c82d3

Please sign in to comment.