aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Security/AuthenticationRepository.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-20 22:52:58 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-20 22:52:58 -0500
commit1dc080df8ba5b9af9245788634d56cb155afd2ba (patch)
tree746452b0013f05987fa35dd404f040cca60dcf58 /Emby.Server.Implementations/Security/AuthenticationRepository.cs
parent985c9111cf14431c3e1a1f94953a6d4422d167ee (diff)
update connections
Diffstat (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs')
-rw-r--r--Emby.Server.Implementations/Security/AuthenticationRepository.cs55
1 files changed, 33 insertions, 22 deletions
diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
index a9141f153..0a598e9a7 100644
--- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs
+++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
@@ -30,9 +30,17 @@ namespace Emby.Server.Implementations.Security
{
using (var connection = CreateConnection())
{
+ connection.ExecuteAll(string.Join(";", new[]
+ {
+ "pragma default_temp_store = memory",
+ "pragma default_synchronous=Normal",
+ "pragma temp_store = memory",
+ "pragma synchronous=Normal",
+ }));
+
string[] queries = {
- "create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
+ "create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
"create index if not exists idx_AccessTokens on AccessTokens(Id)"
};
@@ -63,9 +71,9 @@ namespace Emby.Server.Implementations.Security
cancellationToken.ThrowIfCancellationRequested();
- using (WriteLock.Write())
+ using (var connection = CreateConnection())
{
- using (var connection = CreateConnection())
+ using (WriteLock.Write())
{
connection.RunInTransaction(db =>
{
@@ -200,28 +208,31 @@ namespace Emby.Server.Implementations.Security
var list = new List<AuthenticationInfo>();
- using (var statement = connection.PrepareStatement(commandText))
+ using (WriteLock.Read())
{
- BindAuthenticationQueryParams(query, statement);
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(Get(row));
- }
-
- using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging))
+ using (var statement = connection.PrepareStatement(commandText))
{
- BindAuthenticationQueryParams(query, totalCountStatement);
+ BindAuthenticationQueryParams(query, statement);
- var count = totalCountStatement.ExecuteQuery()
- .SelectScalarInt()
- .First();
+ foreach (var row in statement.ExecuteQuery())
+ {
+ list.Add(Get(row));
+ }
- return new QueryResult<AuthenticationInfo>()
+ using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging))
{
- Items = list.ToArray(),
- TotalRecordCount = count
- };
+ BindAuthenticationQueryParams(query, totalCountStatement);
+
+ var count = totalCountStatement.ExecuteQuery()
+ .SelectScalarInt()
+ .First();
+
+ return new QueryResult<AuthenticationInfo>()
+ {
+ Items = list.ToArray(),
+ TotalRecordCount = count
+ };
+ }
}
}
}
@@ -234,9 +245,9 @@ namespace Emby.Server.Implementations.Security
throw new ArgumentNullException("id");
}
- using (WriteLock.Read())
+ using (var connection = CreateConnection(true))
{
- using (var connection = CreateConnection(true))
+ using (WriteLock.Read())
{
var commandText = BaseSelectText + " where Id=@Id";