fixing bugs in retry stuff

This commit is contained in:
Claus
2018-01-04 11:50:38 +01:00
parent 7c545410cc
commit f238f9fcea

View File

@@ -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;
}
}
}