mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 11:37:32 +09:00
Catch potential file access exceptions also in async flow
This commit is contained in:
parent
682fe5be78
commit
6ec2223b5c
@ -39,25 +39,9 @@ namespace osu.Game.Tests.Database
|
|||||||
|
|
||||||
realmFactory.Dispose();
|
realmFactory.Dispose();
|
||||||
|
|
||||||
try
|
Logger.Log($"Final database size: {getFileSize(testStorage, realmFactory)}");
|
||||||
{
|
|
||||||
Logger.Log($"Final database size: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// windows runs may error due to file still being open.
|
|
||||||
}
|
|
||||||
|
|
||||||
realmFactory.Compact();
|
realmFactory.Compact();
|
||||||
|
Logger.Log($"Final database size after compact: {getFileSize(testStorage, realmFactory)}");
|
||||||
try
|
|
||||||
{
|
|
||||||
Logger.Log($"Final database size after compact: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// windows runs may error due to file still being open.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -71,16 +55,28 @@ namespace osu.Game.Tests.Database
|
|||||||
using (var realmFactory = new RealmContextFactory(testStorage, caller))
|
using (var realmFactory = new RealmContextFactory(testStorage, caller))
|
||||||
{
|
{
|
||||||
Logger.Log($"Running test using realm file {testStorage.GetFullPath(realmFactory.Filename)}");
|
Logger.Log($"Running test using realm file {testStorage.GetFullPath(realmFactory.Filename)}");
|
||||||
|
|
||||||
await testAction(realmFactory, testStorage);
|
await testAction(realmFactory, testStorage);
|
||||||
|
|
||||||
realmFactory.Dispose();
|
realmFactory.Dispose();
|
||||||
Logger.Log($"Final database size: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
|
|
||||||
|
|
||||||
|
Logger.Log($"Final database size: {getFileSize(testStorage, realmFactory)}");
|
||||||
realmFactory.Compact();
|
realmFactory.Compact();
|
||||||
Logger.Log($"Final database size after compact: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
|
Logger.Log($"Final database size after compact: {getFileSize(testStorage, realmFactory)}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long getFileSize(Storage testStorage, RealmContextFactory realmFactory)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return testStorage.GetStream(realmFactory.Filename)?.Length ?? 0;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// windows runs may error due to file still being open.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user