1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +08:00

Fix dangerous File.Copy causing intermittent realm migration test failures

Resolves an issue I've been able to locally reproduce on windows.
Basically, the `File.Copy` would begin while realm was blocking. The
"restore" operation is posted to the `SynchronizationContext` to run on
next update call, but in the mean time the copy would begin, causing a
conflict of interest.

Very dangerous. Only really noticeable on windows.
This commit is contained in:
Dean Herbert 2022-06-24 16:18:51 +09:00
parent 8912f07745
commit 453b77e0dc

View File

@ -254,7 +254,7 @@ namespace osu.Game.Tests.NonVisual
Assert.That(File.Exists(Path.Combine(customPath, OsuGameBase.CLIENT_DATABASE_FILENAME)));
Directory.CreateDirectory(customPath2);
File.Copy(Path.Combine(customPath, OsuGameBase.CLIENT_DATABASE_FILENAME), Path.Combine(customPath2, OsuGameBase.CLIENT_DATABASE_FILENAME));
File.WriteAllText(Path.Combine(customPath2, OsuGameBase.CLIENT_DATABASE_FILENAME), "I am a text");
// Fails because file already exists.
Assert.Throws<ArgumentException>(() => osu.Migrate(customPath2));