Skip to content

Commit 055d2a3

Browse files
authored
fix(rename-overwrite): handle EBUSY error code (#216)
1 parent ef41966 commit 055d2a3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

rename-overwrite/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ module.exports = async function renameOverwrite (oldPath, newPath, retry = 0) {
1919
break
2020
// Windows Antivirus issues
2121
case 'EPERM':
22-
case 'EACCESS': {
22+
case 'EACCESS':
23+
case 'EBUSY': {
2324
await rimraf(newPath)
2425
const start = Date.now()
2526
let backoff = 0
2627
let lastError = err
27-
while (Date.now() - start < 60000 && (lastError.code === 'EPERM' || lastError.code === 'EACCESS')) {
28+
while (Date.now() - start < 60000 && (lastError.code === 'EPERM' || lastError.code === 'EACCESS' || lastError.code === 'EBUSY')) {
2829
await new Promise(resolve => setTimeout(resolve, backoff))
2930
try {
3031
await fs.promises.rename(oldPath, newPath)
@@ -77,12 +78,13 @@ module.exports.sync = function renameOverwriteSync (oldPath, newPath, retry = 0)
7778
switch (err.code) {
7879
// Windows Antivirus issues
7980
case 'EPERM':
80-
case 'EACCESS': {
81+
case 'EACCESS':
82+
case 'EBUSY': {
8183
rimraf.sync(newPath)
8284
const start = Date.now()
8385
let backoff = 0
8486
let lastError = err
85-
while (Date.now() - start < 60000 && (lastError.code === 'EPERM' || lastError.code === 'EACCESS')) {
87+
while (Date.now() - start < 60000 && (lastError.code === 'EPERM' || lastError.code === 'EACCESS' || lastError.code === 'EBUSY')) {
8688
const waitUntil = Date.now() + backoff
8789
while (waitUntil > Date.now()) {}
8890
try {

0 commit comments

Comments
 (0)