U4-10739 - cosmetics

This commit is contained in:
Stephan
2018-01-04 15:34:22 +01:00
parent 79958e0fe0
commit 9883757704

View File

@@ -424,31 +424,26 @@ namespace Umbraco.Core.IO
const int count = 10;
const int pausems = 100;
for (var i = 0;i < count; i++)
for (var i = 0;; i++)
{
try
{
action();
// don't retry if the action succeeded
i = count;
action();
break; // done
}
catch (IOException e)
{
// if it's not *exactly* IOException then it could be
// some inherited exception such as FileNotFoundException,
{
// 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;
// wait and retry
if (i < count-1)
{
Thread.Sleep(pausems);
continue;
}
// throw if out of retries
throw;
// if we have tried enough, throw, else swallow
// the exception and retry after a pause
if (i == count) throw;
}
Thread.Sleep(pausems);
}
}