From cf2bce63862d995d238802ff4a7a24966361360a Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 23 Jul 2024 12:53:02 -0400 Subject: [PATCH] fs: fix regression on rmsync PR-URL: https://github.com/nodejs/node/pull/53982 Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell --- src/node_file.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index c6556725109a6b..a86482b194bff5 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1654,6 +1654,8 @@ static void RmSync(const FunctionCallbackInfo& args) { error == std::errc::operation_not_permitted); }; + int i = 1; + while (maxRetries >= 0) { if (recursive) { std::filesystem::remove_all(file_path, error); @@ -1667,14 +1669,15 @@ static void RmSync(const FunctionCallbackInfo& 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.