diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 879f0ffe5a..df72164b20 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -424,23 +424,31 @@ namespace Umbraco.Core.IO const int count = 10; const int pausems = 100; - for (var i = 0;; i++) + for (var i = 0;i < count; i++) { try { - action(); + action(); + // don't retry if the action succeeded + i = count; } catch (IOException e) { // if it's not *exactly* IOException then it could be // some inherited exception such as FileNotFoundException, // and then we don't want to retry - if (e.GetType() != typeof(IOException)) throw; + if (e.GetType() != typeof(IOException)) throw; - if (i == count) throw; - // else retry - } - Thread.Sleep(pausems); + // wait and retry + if (i < count-1) + { + Thread.Sleep(pausems); + continue; + } + + // throw if out of retries + throw; + } } }