Skip to content

Commit

Permalink
fix: retry rename on EPERM error (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Nov 15, 2023
1 parent 7a71082 commit a681f51
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rename-overwrite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ module.exports.sync = function renameOverwriteSync (oldPath, newPath, retry = 0)
retry++
if (retry > 3) throw err
switch (err.code) {
case 'EPERM': // weird Windows stuff
rimraf.sync(newPath)
renameOverwriteSync(oldPath, newPath, retry)
return
case 'ENOTEMPTY':
case 'EEXIST':
case 'EPERM': // weird Windows stuff
case 'ENOTDIR':
rimraf.sync(newPath)
fs.renameSync(oldPath, newPath)
Expand Down

0 comments on commit a681f51

Please sign in to comment.