update transaction modes

This commit is contained in:
Luke Pulverenti 2016-11-28 14:26:48 -05:00
parent 56b24da151
commit 1c52e4f51b
11 changed files with 40 additions and 33 deletions

View File

@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Activity
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }

View File

@ -30,6 +30,11 @@ namespace Emby.Server.Implementations.Data
get { return false; } get { return false; }
} }
protected TransactionMode TransactionMode
{
get { return TransactionMode.Immediate; }
}
static BaseSqliteRepository() static BaseSqliteRepository()
{ {
SQLite3.EnableSharedCache = false; SQLite3.EnableSharedCache = false;

View File

@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.Data
connection.RunInTransaction(db => connection.RunInTransaction(db =>
{ {
SaveDisplayPreferences(displayPreferences, userId, client, db); SaveDisplayPreferences(displayPreferences, userId, client, db);
}); }, TransactionMode);
} }
} }
} }
@ -147,7 +147,7 @@ namespace Emby.Server.Implementations.Data
{ {
SaveDisplayPreferences(displayPreference, userId, displayPreference.Client, db); SaveDisplayPreferences(displayPreference, userId, displayPreference.Client, db);
} }
}); }, TransactionMode);
} }
} }
} }

View File

@ -85,7 +85,7 @@ namespace Emby.Server.Implementations.Data
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }
@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.Data
statement.TryBind("@ResultId", id.ToGuidParamValue()); statement.TryBind("@ResultId", id.ToGuidParamValue());
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }
@ -124,7 +124,7 @@ namespace Emby.Server.Implementations.Data
var commandText = "delete from FileOrganizerResults"; var commandText = "delete from FileOrganizerResults";
db.Execute(commandText); db.Execute(commandText);
}); }, TransactionMode);
} }
} }
} }

View File

@ -316,7 +316,7 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "MediaStreams", "RefFrames", "INT", existingColumnNames); AddColumn(db, "MediaStreams", "RefFrames", "INT", existingColumnNames);
AddColumn(db, "MediaStreams", "KeyFrames", "TEXT", existingColumnNames); AddColumn(db, "MediaStreams", "KeyFrames", "TEXT", existingColumnNames);
AddColumn(db, "MediaStreams", "IsAnamorphic", "BIT", existingColumnNames); AddColumn(db, "MediaStreams", "IsAnamorphic", "BIT", existingColumnNames);
}); }, TransactionMode);
string[] postQueries = string[] postQueries =
@ -697,7 +697,7 @@ namespace Emby.Server.Implementations.Data
connection.RunInTransaction(db => connection.RunInTransaction(db =>
{ {
SaveItemsInTranscation(db, tuples); SaveItemsInTranscation(db, tuples);
}); }, TransactionMode);
} }
} }
} }
@ -2211,7 +2211,7 @@ namespace Emby.Server.Implementations.Data
index++; index++;
} }
} }
}); }, TransactionMode);
} }
} }
} }
@ -4531,7 +4531,7 @@ namespace Emby.Server.Implementations.Data
// Delete the item // Delete the item
ExecuteWithSingleParam(db, "delete from TypedBaseItems where guid=@Id", id.ToGuidParamValue()); ExecuteWithSingleParam(db, "delete from TypedBaseItems where guid=@Id", id.ToGuidParamValue());
}); }, TransactionMode);
} }
} }
} }

View File

@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "userdata", "AudioStreamIndex", "int", existingColumnNames); AddColumn(db, "userdata", "AudioStreamIndex", "int", existingColumnNames);
AddColumn(db, "userdata", "SubtitleStreamIndex", "int", existingColumnNames); AddColumn(db, "userdata", "SubtitleStreamIndex", "int", existingColumnNames);
}); }, TransactionMode);
ImportUserDataIfNeeded(connection); ImportUserDataIfNeeded(connection);
} }
@ -116,7 +116,7 @@ namespace Emby.Server.Implementations.Data
statement.TryBind("@IsUserDataImported", true); statement.TryBind("@IsUserDataImported", true);
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
private void ImportUserData(IDatabaseConnection connection, string file) private void ImportUserData(IDatabaseConnection connection, string file)
@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Data
connection.RunInTransaction(db => connection.RunInTransaction(db =>
{ {
db.Execute("REPLACE INTO userdata(" + columns + ") SELECT " + columns + " FROM UserDataBackup.userdata;"); db.Execute("REPLACE INTO userdata(" + columns + ") SELECT " + columns + " FROM UserDataBackup.userdata;");
}); }, TransactionMode);
} }
/// <summary> /// <summary>
@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.Data
connection.RunInTransaction(db => connection.RunInTransaction(db =>
{ {
SaveUserData(db, userId, key, userData); SaveUserData(db, userId, key, userData);
}); }, TransactionMode);
} }
} }
} }
@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.Data
{ {
SaveUserData(db, userId, userItemData.Key, userItemData); SaveUserData(db, userId, userItemData.Key, userItemData);
} }
}); }, TransactionMode);
} }
} }
} }

View File

@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Data
statement.TryBind("@data", serialized); statement.TryBind("@data", serialized);
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }
@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.Data
statement.TryBind("@id", user.Id.ToGuidParamValue()); statement.TryBind("@id", user.Id.ToGuidParamValue());
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }

View File

@ -249,7 +249,7 @@ namespace Emby.Server.Implementations.Notifications
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }
@ -304,7 +304,7 @@ namespace Emby.Server.Implementations.Notifications
statement.MoveNext(); statement.MoveNext();
} }
}); }, TransactionMode);
} }
} }
} }
@ -334,7 +334,7 @@ namespace Emby.Server.Implementations.Notifications
} }
} }
}); }, TransactionMode);
} }
} }
} }

View File

@ -50,7 +50,8 @@ namespace Emby.Server.Implementations.Security
var existingColumnNames = GetColumnNames(db, "AccessTokens"); var existingColumnNames = GetColumnNames(db, "AccessTokens");
AddColumn(db, "AccessTokens", "AppVersion", "TEXT", existingColumnNames); AddColumn(db, "AccessTokens", "AppVersion", "TEXT", existingColumnNames);
});
}, TransactionMode);
} }
} }
@ -70,9 +71,9 @@ namespace Emby.Server.Implementations.Security
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
using (WriteLock.Write()) using (var connection = CreateConnection())
{ {
using (var connection = CreateConnection()) using (WriteLock.Write())
{ {
connection.RunInTransaction(db => connection.RunInTransaction(db =>
{ {
@ -100,7 +101,8 @@ namespace Emby.Server.Implementations.Security
statement.MoveNext(); statement.MoveNext();
} }
});
}, TransactionMode);
} }
} }
} }
@ -137,9 +139,9 @@ namespace Emby.Server.Implementations.Security
throw new ArgumentNullException("query"); throw new ArgumentNullException("query");
} }
using (WriteLock.Read()) using (var connection = CreateConnection(true))
{ {
using (var connection = CreateConnection(true)) using (WriteLock.Read())
{ {
var commandText = BaseSelectText; var commandText = BaseSelectText;
@ -244,9 +246,9 @@ namespace Emby.Server.Implementations.Security
throw new ArgumentNullException("id"); 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"; var commandText = BaseSelectText + " where Id=@Id";

View File

@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Social
info.ItemId, info.ItemId,
info.UserId, info.UserId,
info.ExpirationDate.ToDateTimeParamValue()); info.ExpirationDate.ToDateTimeParamValue());
}); }, TransactionMode);
} }
} }
} }

View File

@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Sync
existingColumnNames = GetColumnNames(db, "SyncJobItems"); existingColumnNames = GetColumnNames(db, "SyncJobItems");
AddColumn(db, "SyncJobItems", "ItemDateModifiedTicks", "BIGINT", existingColumnNames); AddColumn(db, "SyncJobItems", "ItemDateModifiedTicks", "BIGINT", existingColumnNames);
}); }, TransactionMode);
} }
} }
@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Sync
connection.RunInTransaction(conn => connection.RunInTransaction(conn =>
{ {
conn.Execute(commandText, paramList.ToArray()); conn.Execute(commandText, paramList.ToArray());
}); }, TransactionMode);
} }
} }
} }
@ -290,7 +290,7 @@ namespace Emby.Server.Implementations.Sync
{ {
conn.Execute("delete from SyncJobs where Id=?", id.ToGuidParamValue()); conn.Execute("delete from SyncJobs where Id=?", id.ToGuidParamValue());
conn.Execute("delete from SyncJobItems where JobId=?", id); conn.Execute("delete from SyncJobItems where JobId=?", id);
}); }, TransactionMode);
} }
} }
} }
@ -743,7 +743,7 @@ namespace Emby.Server.Implementations.Sync
connection.RunInTransaction(conn => connection.RunInTransaction(conn =>
{ {
conn.Execute(commandText, paramList.ToArray()); conn.Execute(commandText, paramList.ToArray());
}); }, TransactionMode);
} }
} }
} }