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 2f86ad88ae
commit 545c04aaf5
1 changed files with 1 additions and 1 deletions

View File

@ -254,7 +254,7 @@ public void TestMigrationFailsOnExistingData()
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));