Skip to content

Commit

Permalink
fs: fix regression on rmsync
Browse files Browse the repository at this point in the history
PR-URL: #53982
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
anonrig authored Jul 23, 2024
1 parent db594d0 commit cf2bce6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,8 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
error == std::errc::operation_not_permitted);
};

int i = 1;

while (maxRetries >= 0) {
if (recursive) {
std::filesystem::remove_all(file_path, error);
Expand All @@ -1667,14 +1669,15 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
break;
}

if (retryDelay != 0) {
if (retryDelay > 0) {
#ifdef _WIN32
Sleep(retryDelay / 1000);
Sleep(i * retryDelay / 1000);
#else
sleep(retryDelay / 1000);
sleep(i * retryDelay / 1000);
#endif
}
maxRetries--;
i++;
}

// On Windows path::c_str() returns wide char, convert to std::string first.
Expand Down

0 comments on commit cf2bce6

Please sign in to comment.