Handle window file access errors

This commit is contained in:
Dean Herbert 2021-10-01 10:40:55 +09:00
parent 74841cf1a9
commit b5345235ca
1 changed files with 18 additions and 2 deletions

View File

@ -38,10 +38,26 @@ protected void RunTestWithRealm(Action<RealmContextFactory, Storage> testAction,
testAction(realmFactory, testStorage);
realmFactory.Dispose();
Logger.Log($"Final database size: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
try
{
Logger.Log($"Final database size: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
}
catch
{
// windows runs may error due to file still being open.
}
realmFactory.Compact();
Logger.Log($"Final database size after compact: {testStorage.GetStream(realmFactory.Filename)?.Length ?? 0}");
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.
}
}
});
}