Throw exception on copy timeout

This commit is contained in:
Dean Herbert 2020-05-13 20:29:15 +09:00
parent 49e616b7e5
commit ad1d050fb4

View File

@ -96,20 +96,7 @@ namespace osu.Game.IO
if (topLevelExcludes && IGNORE_FILES.Contains(fi.Name))
continue;
int tries = 5;
while (tries-- > 0)
{
try
{
fi.CopyTo(Path.Combine(destination.FullName, fi.Name), true);
break;
}
catch (Exception)
{
Thread.Sleep(50);
}
}
attemptCopy(fi, Path.Combine(destination.FullName, fi.Name));
}
foreach (DirectoryInfo dir in source.GetDirectories())
@ -120,5 +107,26 @@ namespace osu.Game.IO
copyRecursive(dir, destination.CreateSubdirectory(dir.Name), false);
}
}
private static void attemptCopy(System.IO.FileInfo fileInfo, string destination)
{
int tries = 5;
while (true)
{
try
{
fileInfo.CopyTo(destination, true);
return;
}
catch (Exception)
{
if (tries-- == 0)
throw;
}
Thread.Sleep(50);
}
}
}
}