diff --git a/osu.Game/IO/MigratableStorage.cs b/osu.Game/IO/MigratableStorage.cs
index 4bc729f429..30e74adca4 100644
--- a/osu.Game/IO/MigratableStorage.cs
+++ b/osu.Game/IO/MigratableStorage.cs
@@ -7,7 +7,6 @@ using System;
using System.IO;
using System.Linq;
using System.Threading;
-using osu.Framework.Logging;
using osu.Framework.Platform;
namespace osu.Game.IO
@@ -17,12 +16,6 @@ namespace osu.Game.IO
///
public abstract class MigratableStorage : WrappedStorage
{
- ///
- /// The number of file copy failures before actually bailing on migration.
- /// This allows some lenience to cover things like temporary files which could not be copied but are also not too important.
- ///
- private const int allowed_failures = 10;
-
///
/// A relative list of directory paths which should not be migrated.
///
@@ -80,7 +73,7 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreFiles.Contains(fi.Name))
continue;
- allFilesDeleted &= AttemptOperation(() => fi.Delete());
+ allFilesDeleted &= AttemptOperation(() => fi.Delete(), throwOnFailure: false);
}
foreach (DirectoryInfo dir in target.GetDirectories())
@@ -88,16 +81,16 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreDirectories.Contains(dir.Name))
continue;
- allFilesDeleted &= AttemptOperation(() => dir.Delete(true));
+ allFilesDeleted &= AttemptOperation(() => dir.Delete(true), throwOnFailure: false);
}
if (target.GetFiles().Length == 0 && target.GetDirectories().Length == 0)
- allFilesDeleted &= AttemptOperation(target.Delete);
+ allFilesDeleted &= AttemptOperation(target.Delete, throwOnFailure: false);
return allFilesDeleted;
}
- protected void CopyRecursive(DirectoryInfo source, DirectoryInfo destination, bool topLevelExcludes = true, int totalFailedOperations = 0)
+ protected void CopyRecursive(DirectoryInfo source, DirectoryInfo destination, bool topLevelExcludes = true)
{
// based off example code https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo
if (!destination.Exists)
@@ -108,14 +101,7 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreFiles.Contains(fi.Name))
continue;
- if (!AttemptOperation(() => fi.CopyTo(Path.Combine(destination.FullName, fi.Name), false)))
- {
- Logger.Log($"Failed to copy file {fi.Name} during folder migration");
- totalFailedOperations++;
-
- if (totalFailedOperations > allowed_failures)
- throw new Exception("Aborting due to too many file copy failures during data migration");
- }
+ AttemptOperation(() => fi.CopyTo(Path.Combine(destination.FullName, fi.Name), true));
}
foreach (DirectoryInfo dir in source.GetDirectories())
@@ -123,7 +109,7 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreDirectories.Contains(dir.Name))
continue;
- CopyRecursive(dir, destination.CreateSubdirectory(dir.Name), false, totalFailedOperations);
+ CopyRecursive(dir, destination.CreateSubdirectory(dir.Name), false);
}
}
@@ -132,7 +118,8 @@ namespace osu.Game.IO
///
/// The action to perform.
/// The number of attempts (250ms wait between each).
- protected static bool AttemptOperation(Action action, int attempts = 10)
+ /// Whether to throw an exception on failure. If false, will silently fail.
+ protected static bool AttemptOperation(Action action, int attempts = 10, bool throwOnFailure = true)
{
while (true)
{
@@ -144,7 +131,12 @@ namespace osu.Game.IO
catch (Exception)
{
if (attempts-- == 0)
+ {
+ if (throwOnFailure)
+ throw;
+
return false;
+ }
}
Thread.Sleep(250);