1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Re-query file existence before failing a recursive copy operation during migration

This commit is contained in:
Dean Herbert 2022-08-01 17:01:19 +09:00
parent 59210ecc9d
commit cc8a71b65d

View File

@ -96,12 +96,22 @@ namespace osu.Game.IO
if (!destination.Exists) if (!destination.Exists)
Directory.CreateDirectory(destination.FullName); Directory.CreateDirectory(destination.FullName);
foreach (System.IO.FileInfo fi in source.GetFiles()) foreach (System.IO.FileInfo fileInfo in source.GetFiles())
{ {
if (topLevelExcludes && IgnoreFiles.Contains(fi.Name)) if (topLevelExcludes && IgnoreFiles.Contains(fileInfo.Name))
continue; continue;
AttemptOperation(() => fi.CopyTo(Path.Combine(destination.FullName, fi.Name), true)); AttemptOperation(() =>
{
fileInfo.Refresh();
// A temporary file may have been deleted since the initial GetFiles operation.
// We don't want the whole migration process to fail in such a case.
if (!fileInfo.Exists)
return;
fileInfo.CopyTo(Path.Combine(destination.FullName, fileInfo.Name), true);
});
} }
foreach (DirectoryInfo dir in source.GetDirectories()) foreach (DirectoryInfo dir in source.GetDirectories())