aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Sync/SyncRepository.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/Sync/SyncRepository.cs
parent985c9111cf14431c3e1a1f94953a6d4422d167ee (diff)
update connections
Diffstat (limited to 'Emby.Server.Implementations/Sync/SyncRepository.cs')
-rw-r--r--Emby.Server.Implementations/Sync/SyncRepository.cs76
1 files changed, 42 insertions, 34 deletions
diff --git a/Emby.Server.Implementations/Sync/SyncRepository.cs b/Emby.Server.Implementations/Sync/SyncRepository.cs
index 6fb918f15..36558142b 100644
--- a/Emby.Server.Implementations/Sync/SyncRepository.cs
+++ b/Emby.Server.Implementations/Sync/SyncRepository.cs
@@ -43,6 +43,14 @@ namespace Emby.Server.Implementations.Sync
{
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 SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
@@ -95,9 +103,9 @@ namespace Emby.Server.Implementations.Sync
throw new ArgumentNullException("id");
}
- using (WriteLock.Read())
+ using (var connection = CreateConnection(true))
{
- using (var connection = CreateConnection(true))
+ using (WriteLock.Read())
{
var commandText = BaseJobSelectText + " where Id=?";
var paramList = new List<object>();
@@ -206,9 +214,9 @@ namespace Emby.Server.Implementations.Sync
CheckDisposed();
- using (WriteLock.Write())
+ using (var connection = CreateConnection())
{
- using (var connection = CreateConnection())
+ using (WriteLock.Write())
{
string commandText;
var paramList = new List<object>();
@@ -259,9 +267,9 @@ namespace Emby.Server.Implementations.Sync
CheckDisposed();
- using (WriteLock.Write())
+ using (var connection = CreateConnection())
{
- using (var connection = CreateConnection())
+ using (WriteLock.Write())
{
connection.RunInTransaction(conn =>
{
@@ -281,9 +289,9 @@ namespace Emby.Server.Implementations.Sync
CheckDisposed();
- using (WriteLock.Read())
+ using (var connection = CreateConnection(true))
{
- using (var connection = CreateConnection(true))
+ using (WriteLock.Read())
{
var commandText = BaseJobSelectText;
var paramList = new List<object>();
@@ -379,11 +387,11 @@ namespace Emby.Server.Implementations.Sync
CheckDisposed();
- using (WriteLock.Read())
- {
- var guid = new Guid(id);
+ var guid = new Guid(id);
- using (var connection = CreateConnection(true))
+ using (var connection = CreateConnection(true))
+ {
+ using (WriteLock.Read())
{
var commandText = BaseJobItemSelectText + " where Id=?";
var paramList = new List<object>();
@@ -407,9 +415,9 @@ namespace Emby.Server.Implementations.Sync
throw new ArgumentNullException("query");
}
- using (WriteLock.Read())
+ using (var connection = CreateConnection(true))
{
- using (var connection = CreateConnection(true))
+ using (WriteLock.Read())
{
var commandText = baseSelectText;
var paramList = new List<object>();
@@ -487,30 +495,30 @@ namespace Emby.Server.Implementations.Sync
var now = DateTime.UtcNow;
- using (WriteLock.Read())
+ using (var connection = CreateConnection(true))
{
- using (var connection = CreateConnection(true))
- {
- var commandText = "select ItemId,Status,Progress from SyncJobItems";
- var whereClauses = new List<string>();
+ var commandText = "select ItemId,Status,Progress from SyncJobItems";
+ var whereClauses = new List<string>();
- if (!string.IsNullOrWhiteSpace(query.TargetId))
- {
- whereClauses.Add("TargetId=@TargetId");
- }
+ if (!string.IsNullOrWhiteSpace(query.TargetId))
+ {
+ whereClauses.Add("TargetId=@TargetId");
+ }
- if (query.Statuses.Length > 0)
- {
- var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray());
+ if (query.Statuses.Length > 0)
+ {
+ var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray());
- whereClauses.Add(string.Format("Status in ({0})", statuses));
- }
+ whereClauses.Add(string.Format("Status in ({0})", statuses));
+ }
- if (whereClauses.Count > 0)
- {
- commandText += " where " + string.Join(" AND ", whereClauses.ToArray());
- }
+ if (whereClauses.Count > 0)
+ {
+ commandText += " where " + string.Join(" AND ", whereClauses.ToArray());
+ }
+ using (WriteLock.Read())
+ {
using (var statement = connection.PrepareStatement(commandText))
{
if (!string.IsNullOrWhiteSpace(query.TargetId))
@@ -664,9 +672,9 @@ namespace Emby.Server.Implementations.Sync
CheckDisposed();
- using (WriteLock.Write())
+ using (var connection = CreateConnection())
{
- using (var connection = CreateConnection())
+ using (WriteLock.Write())
{
string commandText;