Commit fb56ac92 authored by Kyle Edwards's avatar Kyle Edwards Committed by Kitware Robot

Merge topic 'retry-directory-delete'

6bc77966 Retry removing directories on Windows
57295803 Use registry setting for removal retry count and delay
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3667
parents 39d2ce4a 6bc77966
Pipeline #143702 passed with stage
in 0 seconds
......@@ -1356,7 +1356,7 @@ bool HandleRemoveImpl(std::vector<std::string> const& args, bool recurse,
if (cmSystemTools::FileIsDirectory(fileName) &&
!cmSystemTools::FileIsSymlink(fileName) && recurse) {
cmSystemTools::RemoveADirectory(fileName);
cmSystemTools::RepeatedRemoveDirectory(fileName);
} else {
cmSystemTools::RemoveFile(fileName);
}
......
......@@ -2838,14 +2838,20 @@ bool cmSystemTools::CheckRPath(std::string const& file,
bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir)
{
#ifdef _WIN32
// Windows sometimes locks files temporarily so try a few times.
for (int i = 0; i < 10; ++i) {
WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry();
for (unsigned int i = 0; i < retry.Count; ++i) {
if (cmSystemTools::RemoveADirectory(dir)) {
return true;
}
cmSystemTools::Delay(100);
cmSystemTools::Delay(retry.Delay);
}
return false;
#else
return cmSystemTools::RemoveADirectory(dir);
#endif
}
bool cmSystemTools::StringToLong(const char* str, long* value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment