protected SQLiteConnection GetConnection()
{
try
{
var dir = Path.GetDirectoryName(Configuration.LibraryConfiguration.Instance.StoragePath);
if (String.IsNullOrEmpty(dir))
{
throw new InvalidOperationException("Invalid path to the database.");
}
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
var connection = new SQLiteConnection(ConnectionString);
connection.Open();
_schemaManager.CheckSchema(connection);
return connection;
}
catch (Exception ex)
{
_log.Error("Unable to establish proper connection to database.", ex);
throw new StorageException("Unable to establish proper connection to database.", ex);
}
}