public async Task EnsureAvailableAsync() {
Version CurrentVersion = null;
try {
// Test query.
CurrentVersion = await Task.Run(() => VersionAccess.GetVersionInfo());
} catch {
}
if (CurrentVersion == null) {
// Check if database exists. If it doesn't, create blank database.
if (!File.Exists(Settings.DatabasePath) || new FileInfo(Settings.DatabasePath).Length == 0)
await CreateNewDatabaseAsync();
await TryUntilTimeout(() => VersionAccess.GetVersionInfo(), 10000);
}
// If database connection is successfull, ensure database file is up to date.
await UpdateDatabaseAsync();
}