update repositories

pull/702/head
Luke Pulverenti 8 years ago
parent 9ecfb4fd82
commit 61e195c096

@ -27,15 +27,9 @@ namespace Emby.Server.Implementations.Activity
{
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 = {
"create table if not exists ActivityLogEntries (Id GUID PRIMARY KEY, Name TEXT, Overview TEXT, ShortOverview TEXT, Type TEXT, ItemId TEXT, UserId TEXT, DateCreated DATETIME, LogSeverity TEXT)",
"create index if not exists idx_ActivityLogEntries on ActivityLogEntries(Id)"
};
@ -58,9 +52,9 @@ namespace Emby.Server.Implementations.Activity
throw new ArgumentNullException("entry");
}
using (WriteLock.Write())
{
using (var connection = CreateConnection())
{
using (WriteLock.Write())
{
connection.RunInTransaction(db =>
{
@ -85,10 +79,10 @@ namespace Emby.Server.Implementations.Activity
}
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit)
{
using (WriteLock.Read())
{
using (var connection = CreateConnection(true))
{
using (WriteLock.Read())
{
var commandText = BaseActivitySelectText;
var whereClauses = new List<string>();

@ -67,20 +67,8 @@ namespace Emby.Server.Implementations.Data
//Logger.Info("Opening write connection");
}
isReadOnly = false;
if (isReadOnly)
{
connectionFlags = ConnectionFlags.ReadOnly;
//connectionFlags = ConnectionFlags.Create;
//connectionFlags |= ConnectionFlags.ReadWrite;
}
else
{
connectionFlags = ConnectionFlags.Create;
connectionFlags |= ConnectionFlags.ReadWrite;
}
connectionFlags |= ConnectionFlags.SharedCached;
connectionFlags |= ConnectionFlags.NoMutex;
@ -89,6 +77,8 @@ namespace Emby.Server.Implementations.Data
if (string.IsNullOrWhiteSpace(_defaultWal))
{
_defaultWal = db.Query("PRAGMA journal_mode").SelectScalarString().First();
Logger.Info("Default journal_mode for {0} is {1}", DbFilePath, _defaultWal);
}
var queries = new List<string>
@ -115,7 +105,7 @@ namespace Emby.Server.Implementations.Data
//Logger.Info("synchronous: " + db.Query("PRAGMA synchronous").SelectScalarString().First());
//Logger.Info("temp_store: " + db.Query("PRAGMA temp_store").SelectScalarString().First());
if (!string.Equals(_defaultWal, "wal", StringComparison.OrdinalIgnoreCase))
/*if (!string.Equals(_defaultWal, "wal", StringComparison.OrdinalIgnoreCase))
{
queries.Add("PRAGMA journal_mode=WAL");
@ -124,7 +114,7 @@ namespace Emby.Server.Implementations.Data
db.ExecuteAll(string.Join(";", queries.ToArray()));
}
}
else if (queries.Count > 0)
else*/ if (queries.Count > 0)
{
db.ExecuteAll(string.Join(";", queries.ToArray()));
}
@ -132,6 +122,26 @@ namespace Emby.Server.Implementations.Data
return db;
}
protected void RunDefaultInitialization(IDatabaseConnection db)
{
var queries = new List<string>
{
"PRAGMA journal_mode=WAL",
"PRAGMA page_size=4096",
};
if (EnableTempStoreMemory)
{
queries.AddRange(new List<string>
{
"pragma default_temp_store = memory",
"pragma temp_store = memory"
});
}
db.ExecuteAll(string.Join(";", queries.ToArray()));
}
protected virtual bool EnableTempStoreMemory
{
get

@ -54,12 +54,7 @@ namespace Emby.Server.Implementations.Data
{
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 = {

@ -31,12 +31,7 @@ namespace Emby.Server.Implementations.Data
{
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 = {

@ -157,12 +157,7 @@ namespace Emby.Server.Implementations.Data
{
using (var connection = CreateConnection())
{
connection.ExecuteAll(string.Join(";", new[]
{
"PRAGMA page_size=4096",
"PRAGMA default_temp_store=memory",
"PRAGMA temp_store=memory"
}));
RunDefaultInitialization(connection);
var createMediaStreamsTableCommand
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
@ -395,10 +390,10 @@ namespace Emby.Server.Implementations.Data
private void OnShrinkMemoryTimerCallback(object state)
{
try
{
using (WriteLock.Write())
{
using (var connection = CreateConnection())
{
using (WriteLock.Write())
{
connection.RunQueries(new string[]
{

@ -51,8 +51,6 @@ namespace Emby.Server.Implementations.Data
{
string[] queries = {
"pragma temp_store = memory",
"create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
"create table if not exists DataSettings (IsUserDataImported bit)",

@ -50,12 +50,7 @@ namespace Emby.Server.Implementations.Data
{
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 = {

@ -29,12 +29,7 @@ namespace Emby.Server.Implementations.Notifications
{
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 = {
@ -58,7 +53,7 @@ namespace Emby.Server.Implementations.Notifications
using (var connection = CreateConnection(true))
{
//using (WriteLock.Read())
using (WriteLock.Read())
{
var clauses = new List<string>();
var paramList = new List<object>();
@ -113,7 +108,7 @@ namespace Emby.Server.Implementations.Notifications
using (var connection = CreateConnection(true))
{
//using (WriteLock.Read())
using (WriteLock.Read())
{
using (var statement = connection.PrepareStatement("select Level from Notifications where UserId=@UserId and IsRead=@IsRead"))
{

@ -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,10 +134,6 @@ namespace Emby.Server.Implementations.Security
throw new ArgumentNullException("query");
}
using (var connection = CreateConnection(true))
{
using (WriteLock.Read())
{
var commandText = BaseSelectText;
var whereClauses = new List<string>();
@ -211,6 +202,10 @@ namespace Emby.Server.Implementations.Security
var list = new List<AuthenticationInfo>();
using (var connection = CreateConnection(true))
{
using (WriteLock.Read())
{
using (var statement = connection.PrepareStatement(commandText))
{
BindAuthenticationQueryParams(query, statement);

@ -27,12 +27,7 @@ namespace Emby.Server.Implementations.Social
{
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 = {

@ -43,12 +43,7 @@ namespace Emby.Server.Implementations.Sync
{
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 = {

Loading…
Cancel
Save