1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-23 03:33:59 +00:00

background thread full/incremental sync operations. pool sqlconnection. sqlconnection to FullMutex mode for multithread environment. try/catch decryption errors.

This commit is contained in:
Kyle Spearrin
2016-07-06 22:33:50 -04:00
parent 0be15d7a34
commit 29c7a0ccf0
4 changed files with 104 additions and 71 deletions

View File

@@ -2,24 +2,31 @@
using System.IO;
using Bit.App.Abstractions;
using Foundation;
using SQLite;
namespace Bit.iOS.Core.Services
{
public class SqlService : ISqlService
{
public SQLite.SQLiteConnection GetConnection()
private SQLiteConnection _connection;
public SQLiteConnection GetConnection()
{
if(_connection != null)
{
return _connection;
}
var sqliteFilename = "bitwarden.db3";
var fileManager = new NSFileManager();
var appGroupContainer = fileManager.GetContainerUrl("group.com.8bit.bitwarden");
var libraryPath = Path.Combine(appGroupContainer.Path, "Library"); // Library folder
var path = Path.Combine(libraryPath, sqliteFilename);
Console.WriteLine(path);
var conn = new SQLite.SQLiteConnection(path);
// Return the database connection
return conn;
_connection = new SQLiteConnection(path,
SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache);
return _connection;
}
}
}