diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-29 14:12:37 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-29 14:12:37 -0500 |
| commit | 61e195c096dfc2c5713bbbcbc0be73ddff99cb55 (patch) | |
| tree | 5680960d1898267b29d8de42eda0e5ec9ab6e0d7 /Emby.Server.Implementations/Security/AuthenticationRepository.cs | |
| parent | 9ecfb4fd823be8fbca8e9bbc242fc8a025c6d3a5 (diff) | |
update repositories
Diffstat (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Security/AuthenticationRepository.cs | 119 |
1 files changed, 57 insertions, 62 deletions
diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index e498253c3..dbda4a460 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -30,12 +30,7 @@ namespace Emby.Server.Implementations.Security { using (var connection = CreateConnection()) { - connection.ExecuteAll(string.Join(";", new[] - { - "PRAGMA page_size=4096", - "pragma default_temp_store = memory", - "pragma temp_store = memory" - })); + RunDefaultInitialization(connection); string[] queries = { @@ -139,78 +134,78 @@ namespace Emby.Server.Implementations.Security throw new ArgumentNullException("query"); } - using (var connection = CreateConnection(true)) - { - using (WriteLock.Read()) - { - var commandText = BaseSelectText; + var commandText = BaseSelectText; - var whereClauses = new List<string>(); + var whereClauses = new List<string>(); - var startIndex = query.StartIndex ?? 0; + var startIndex = query.StartIndex ?? 0; - if (!string.IsNullOrWhiteSpace(query.AccessToken)) - { - whereClauses.Add("AccessToken=@AccessToken"); - } + if (!string.IsNullOrWhiteSpace(query.AccessToken)) + { + whereClauses.Add("AccessToken=@AccessToken"); + } - if (!string.IsNullOrWhiteSpace(query.UserId)) - { - whereClauses.Add("UserId=@UserId"); - } + if (!string.IsNullOrWhiteSpace(query.UserId)) + { + whereClauses.Add("UserId=@UserId"); + } - if (!string.IsNullOrWhiteSpace(query.DeviceId)) - { - whereClauses.Add("DeviceId=@DeviceId"); - } + if (!string.IsNullOrWhiteSpace(query.DeviceId)) + { + whereClauses.Add("DeviceId=@DeviceId"); + } - if (query.IsActive.HasValue) - { - whereClauses.Add("IsActive=@IsActive"); - } + if (query.IsActive.HasValue) + { + whereClauses.Add("IsActive=@IsActive"); + } - if (query.HasUser.HasValue) - { - if (query.HasUser.Value) - { - whereClauses.Add("UserId not null"); - } - else - { - whereClauses.Add("UserId is null"); - } - } + if (query.HasUser.HasValue) + { + if (query.HasUser.Value) + { + whereClauses.Add("UserId not null"); + } + else + { + whereClauses.Add("UserId is null"); + } + } - var whereTextWithoutPaging = whereClauses.Count == 0 ? - string.Empty : - " where " + string.Join(" AND ", whereClauses.ToArray()); + var whereTextWithoutPaging = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray()); - if (startIndex > 0) - { - var pagingWhereText = whereClauses.Count == 0 ? - string.Empty : - " where " + string.Join(" AND ", whereClauses.ToArray()); + if (startIndex > 0) + { + var pagingWhereText = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray()); - whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM AccessTokens {0} ORDER BY DateCreated LIMIT {1})", - pagingWhereText, - startIndex.ToString(_usCulture))); - } + whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM AccessTokens {0} ORDER BY DateCreated LIMIT {1})", + pagingWhereText, + startIndex.ToString(_usCulture))); + } - var whereText = whereClauses.Count == 0 ? - string.Empty : - " where " + string.Join(" AND ", whereClauses.ToArray()); + var whereText = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray()); - commandText += whereText; + commandText += whereText; - commandText += " ORDER BY DateCreated"; + commandText += " ORDER BY DateCreated"; - if (query.Limit.HasValue) - { - commandText += " LIMIT " + query.Limit.Value.ToString(_usCulture); - } + if (query.Limit.HasValue) + { + commandText += " LIMIT " + query.Limit.Value.ToString(_usCulture); + } - var list = new List<AuthenticationInfo>(); + var list = new List<AuthenticationInfo>(); + using (var connection = CreateConnection(true)) + { + using (WriteLock.Read()) + { using (var statement = connection.PrepareStatement(commandText)) { BindAuthenticationQueryParams(query, statement); |
