diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2019-08-13 14:06:44 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-08-13 10:07:09 -0400 |
commit | fb56ac9209f368712284a3705c0d52ba6f55b6ed (patch) | |
tree | f66bf0fc2c0c1ffe06a6f05cba174d3630182c70 | |
parent | 39d2ce4a71c7c337060bdbe68e3ac20178789300 (diff) | |
parent | 6bc77966ad7cce3f12d35e64bcda4be56094b2ca (diff) | |
download | cmake-fb56ac9209f368712284a3705c0d52ba6f55b6ed.tar.gz |
Merge topic 'retry-directory-delete'
6bc77966ad Retry removing directories on Windows
5729580376 Use registry setting for removal retry count and delay
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3667
-rw-r--r-- | Source/cmFileCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index fd319f6b12..d76692ce05 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -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); } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 785e221ba9..ee60f163a0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -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) |