commit
f80cc1bbd4
|
@ -105,5 +105,10 @@ namespace Emby.Common.Implementations.EnvironmentInfo
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string StackTrace
|
||||||
|
{
|
||||||
|
get { return Environment.StackTrace; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,7 +551,7 @@ namespace Emby.Server.Core
|
||||||
DisplayPreferencesRepository = displayPreferencesRepo;
|
DisplayPreferencesRepository = displayPreferencesRepo;
|
||||||
RegisterSingleInstance(DisplayPreferencesRepository);
|
RegisterSingleInstance(DisplayPreferencesRepository);
|
||||||
|
|
||||||
var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager.GetLogger("SqliteItemRepository"), MemoryStreamFactory, assemblyInfo, FileSystemManager);
|
var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager.GetLogger("SqliteItemRepository"), MemoryStreamFactory, assemblyInfo, FileSystemManager, EnvironmentInfo);
|
||||||
ItemRepository = itemRepo;
|
ItemRepository = itemRepo;
|
||||||
RegisterSingleInstance(ItemRepository);
|
RegisterSingleInstance(ItemRepository);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,13 @@ namespace Emby.Server.Implementations.Activity
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
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 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)",
|
||||||
|
@ -51,9 +58,9 @@ namespace Emby.Server.Implementations.Activity
|
||||||
throw new ArgumentNullException("entry");
|
throw new ArgumentNullException("entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
|
@ -79,9 +86,9 @@ namespace Emby.Server.Implementations.Activity
|
||||||
|
|
||||||
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit)
|
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
var commandText = BaseActivitySelectText;
|
var commandText = BaseActivitySelectText;
|
||||||
var whereClauses = new List<string>();
|
var whereClauses = new List<string>();
|
||||||
|
|
|
@ -30,11 +30,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool EnableConnectionPooling
|
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
static BaseSqliteRepository()
|
static BaseSqliteRepository()
|
||||||
{
|
{
|
||||||
SQLite3.EnableSharedCache = false;
|
SQLite3.EnableSharedCache = false;
|
||||||
|
@ -45,7 +40,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
private static bool _versionLogged;
|
private static bool _versionLogged;
|
||||||
|
|
||||||
protected virtual SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false)
|
private string _defaultWal;
|
||||||
|
|
||||||
|
protected SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false, Action<SQLiteDatabaseConnection> onConnect = null)
|
||||||
{
|
{
|
||||||
if (!_versionLogged)
|
if (!_versionLogged)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +53,16 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
ConnectionFlags connectionFlags;
|
ConnectionFlags connectionFlags;
|
||||||
|
|
||||||
//isReadOnly = false;
|
if (isReadOnly)
|
||||||
|
{
|
||||||
|
//Logger.Info("Opening read connection");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Logger.Info("Opening write connection");
|
||||||
|
}
|
||||||
|
|
||||||
|
isReadOnly = false;
|
||||||
|
|
||||||
if (isReadOnly)
|
if (isReadOnly)
|
||||||
{
|
{
|
||||||
|
@ -70,46 +76,50 @@ namespace Emby.Server.Implementations.Data
|
||||||
connectionFlags |= ConnectionFlags.ReadWrite;
|
connectionFlags |= ConnectionFlags.ReadWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EnableConnectionPooling)
|
connectionFlags |= ConnectionFlags.SharedCached;
|
||||||
{
|
|
||||||
connectionFlags |= ConnectionFlags.SharedCached;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connectionFlags |= ConnectionFlags.PrivateCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
connectionFlags |= ConnectionFlags.NoMutex;
|
connectionFlags |= ConnectionFlags.NoMutex;
|
||||||
|
|
||||||
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
|
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(_defaultWal))
|
||||||
|
{
|
||||||
|
_defaultWal = db.Query("PRAGMA journal_mode").SelectScalarString().First();
|
||||||
|
}
|
||||||
|
|
||||||
var queries = new List<string>
|
var queries = new List<string>
|
||||||
{
|
{
|
||||||
"pragma default_temp_store = memory",
|
"PRAGMA default_temp_store=memory",
|
||||||
"PRAGMA page_size=4096",
|
"pragma temp_store = memory",
|
||||||
"PRAGMA journal_mode=WAL",
|
"PRAGMA journal_mode=WAL"
|
||||||
"PRAGMA temp_store=memory",
|
|
||||||
"PRAGMA synchronous=Normal",
|
|
||||||
//"PRAGMA cache size=-10000"
|
//"PRAGMA cache size=-10000"
|
||||||
};
|
};
|
||||||
|
|
||||||
var cacheSize = CacheSize;
|
//var cacheSize = CacheSize;
|
||||||
if (cacheSize.HasValue)
|
//if (cacheSize.HasValue)
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EnableExclusiveMode)
|
|
||||||
{
|
|
||||||
queries.Add("PRAGMA locking_mode=EXCLUSIVE");
|
|
||||||
}
|
|
||||||
|
|
||||||
//foreach (var query in queries)
|
|
||||||
//{
|
//{
|
||||||
// db.Execute(query);
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
db.ExecuteAll(string.Join(";", queries.ToArray()));
|
////foreach (var query in queries)
|
||||||
|
////{
|
||||||
|
//// db.Execute(query);
|
||||||
|
////}
|
||||||
|
|
||||||
|
//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) || onConnect != null)
|
||||||
|
{
|
||||||
|
using (WriteLock.Write())
|
||||||
|
{
|
||||||
|
db.ExecuteAll(string.Join(";", queries.ToArray()));
|
||||||
|
|
||||||
|
if (onConnect != null)
|
||||||
|
{
|
||||||
|
onConnect(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
@ -122,11 +132,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool EnableExclusiveMode
|
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void CheckOk(int rc)
|
internal static void CheckOk(int rc)
|
||||||
{
|
{
|
||||||
string msg = "";
|
string msg = "";
|
||||||
|
|
|
@ -54,9 +54,16 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists userdisplaypreferences (id GUID, userId GUID, client text, data BLOB)",
|
"create table if not exists userdisplaypreferences (id GUID, userId GUID, client text, data BLOB)",
|
||||||
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)"
|
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,9 +93,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
|
@ -130,9 +137,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
|
@ -162,9 +169,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
var guidId = displayPreferencesId.GetMD5();
|
var guidId = displayPreferencesId.GetMD5();
|
||||||
|
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where id = @id and userId=@userId and client=@client"))
|
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where id = @id and userId=@userId and client=@client"))
|
||||||
{
|
{
|
||||||
|
@ -196,9 +203,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
var list = new List<DisplayPreferences>();
|
var list = new List<DisplayPreferences>();
|
||||||
|
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where userId=@userId"))
|
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where userId=@userId"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,11 +131,13 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
public static void Attach(IDatabaseConnection db, string path, string alias)
|
public static void Attach(IDatabaseConnection db, string path, string alias)
|
||||||
{
|
{
|
||||||
var commandText = string.Format("attach ? as {0};", alias);
|
var commandText = string.Format("attach @path as {0};", alias);
|
||||||
var paramList = new List<object>();
|
|
||||||
paramList.Add(path);
|
|
||||||
|
|
||||||
db.Execute(commandText, paramList.ToArray());
|
using (var statement = db.PrepareStatement(commandText))
|
||||||
|
{
|
||||||
|
statement.TryBind("@path", path);
|
||||||
|
statement.MoveNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDBNull(this IReadOnlyList<IResultSetValue> result, int index)
|
public static bool IsDBNull(this IReadOnlyList<IResultSetValue> result, int index)
|
||||||
|
|
|
@ -31,6 +31,13 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists FileOrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, FileLength INT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)",
|
"create table if not exists FileOrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, FileLength INT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,19 +14,12 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository
|
public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository
|
||||||
{
|
{
|
||||||
private SQLiteDatabaseConnection _connection;
|
|
||||||
|
|
||||||
public SqliteUserDataRepository(ILogger logger, IApplicationPaths appPaths)
|
public SqliteUserDataRepository(ILogger logger, IApplicationPaths appPaths)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
{
|
{
|
||||||
DbFilePath = Path.Combine(appPaths.DataPath, "userdata_v2.db");
|
DbFilePath = Path.Combine(appPaths.DataPath, "userdata_v2.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool EnableConnectionPooling
|
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the repository
|
/// Gets the name of the repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -43,13 +36,23 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// Opens the connection to the database
|
/// Opens the connection to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public void Initialize(SQLiteDatabaseConnection connection, ReaderWriterLockSlim writeLock)
|
public void Initialize(ReaderWriterLockSlim writeLock)
|
||||||
{
|
{
|
||||||
WriteLock.Dispose();
|
WriteLock.Dispose();
|
||||||
WriteLock = writeLock;
|
WriteLock = writeLock;
|
||||||
_connection = connection;
|
|
||||||
|
|
||||||
string[] queries = {
|
using (var connection = CreateConnection())
|
||||||
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
|
string[] queries = {
|
||||||
|
|
||||||
|
"PRAGMA locking_mode=NORMAL",
|
||||||
|
|
||||||
"create table if not exists UserDataDb.userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
"create table if not exists UserDataDb.userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
||||||
|
|
||||||
|
@ -69,15 +72,16 @@ namespace Emby.Server.Implementations.Data
|
||||||
"pragma shrink_memory"
|
"pragma shrink_memory"
|
||||||
};
|
};
|
||||||
|
|
||||||
_connection.RunQueries(queries);
|
connection.RunQueries(queries);
|
||||||
|
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
var existingColumnNames = GetColumnNames(db, "userdata");
|
var existingColumnNames = GetColumnNames(db, "userdata");
|
||||||
|
|
||||||
AddColumn(db, "userdata", "AudioStreamIndex", "int", existingColumnNames);
|
AddColumn(db, "userdata", "AudioStreamIndex", "int", existingColumnNames);
|
||||||
AddColumn(db, "userdata", "SubtitleStreamIndex", "int", existingColumnNames);
|
AddColumn(db, "userdata", "SubtitleStreamIndex", "int", existingColumnNames);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -139,18 +143,21 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
_connection.RunInTransaction(db =>
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
SaveUserData(db, userId, key, userData);
|
connection.RunInTransaction(db =>
|
||||||
});
|
{
|
||||||
|
SaveUserData(db, userId, key, userData);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveUserData(IDatabaseConnection db, Guid userId, string key, UserItemData userData)
|
private void SaveUserData(IDatabaseConnection db, Guid userId, string key, UserItemData userData)
|
||||||
{
|
{
|
||||||
using (var statement = _connection.PrepareStatement("replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)"))
|
using (var statement = db.PrepareStatement("replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)"))
|
||||||
{
|
{
|
||||||
statement.TryBind("@UserId", userId.ToGuidParamValue());
|
statement.TryBind("@UserId", userId.ToGuidParamValue());
|
||||||
statement.TryBind("@Key", key);
|
statement.TryBind("@Key", key);
|
||||||
|
@ -207,15 +214,18 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
_connection.RunInTransaction(db =>
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
foreach (var userItemData in userDataList)
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
SaveUserData(db, userId, userItemData.Key, userItemData);
|
foreach (var userItemData in userDataList)
|
||||||
}
|
{
|
||||||
});
|
SaveUserData(db, userId, userItemData.Key, userItemData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,16 +251,19 @@ namespace Emby.Server.Implementations.Data
|
||||||
throw new ArgumentNullException("key");
|
throw new ArgumentNullException("key");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var statement = _connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key =@Key and userId=@UserId"))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
statement.TryBind("@UserId", userId.ToGuidParamValue());
|
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key =@Key and userId=@UserId"))
|
||||||
statement.TryBind("@Key", key);
|
|
||||||
|
|
||||||
foreach (var row in statement.ExecuteQuery())
|
|
||||||
{
|
{
|
||||||
return ReadRow(row);
|
statement.TryBind("@UserId", userId.ToGuidParamValue());
|
||||||
|
statement.TryBind("@Key", key);
|
||||||
|
|
||||||
|
foreach (var row in statement.ExecuteQuery())
|
||||||
|
{
|
||||||
|
return ReadRow(row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,15 +304,18 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
var list = new List<UserItemData>();
|
var list = new List<UserItemData>();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var statement = _connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@UserId"))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
statement.TryBind("@UserId", userId.ToGuidParamValue());
|
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@UserId"))
|
||||||
|
|
||||||
foreach (var row in statement.ExecuteQuery())
|
|
||||||
{
|
{
|
||||||
list.Add(ReadRow(row));
|
statement.TryBind("@UserId", userId.ToGuidParamValue());
|
||||||
|
|
||||||
|
foreach (var row in statement.ExecuteQuery())
|
||||||
|
{
|
||||||
|
list.Add(ReadRow(row));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,13 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists users (guid GUID primary key, data BLOB)",
|
"create table if not exists users (guid GUID primary key, data BLOB)",
|
||||||
|
@ -83,9 +90,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
|
@ -108,9 +115,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
var list = new List<User>();
|
var list = new List<User>();
|
||||||
|
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
foreach (var row in connection.Query("select guid,data from users"))
|
foreach (var row in connection.Query("select guid,data from users"))
|
||||||
{
|
{
|
||||||
|
@ -146,9 +153,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -482,7 +482,7 @@ namespace Emby.Server.Implementations.Dto
|
||||||
{
|
{
|
||||||
if (dtoOptions.EnableUserData)
|
if (dtoOptions.EnableUserData)
|
||||||
{
|
{
|
||||||
dto.UserData = _userDataRepository.GetUserDataDto(item, user).Result;
|
dto.UserData = await _userDataRepository.GetUserDataDto(item, user).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,11 +1450,19 @@ namespace Emby.Server.Implementations.Dto
|
||||||
|
|
||||||
private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem owner)
|
private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem owner)
|
||||||
{
|
{
|
||||||
|
if (!item.SupportsInheritedParentImages)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var logoLimit = options.GetImageLimit(ImageType.Logo);
|
var logoLimit = options.GetImageLimit(ImageType.Logo);
|
||||||
var artLimit = options.GetImageLimit(ImageType.Art);
|
var artLimit = options.GetImageLimit(ImageType.Art);
|
||||||
var thumbLimit = options.GetImageLimit(ImageType.Thumb);
|
var thumbLimit = options.GetImageLimit(ImageType.Thumb);
|
||||||
var backdropLimit = options.GetImageLimit(ImageType.Backdrop);
|
var backdropLimit = options.GetImageLimit(ImageType.Backdrop);
|
||||||
|
|
||||||
|
// For now. Emby apps are not using this
|
||||||
|
artLimit = 0;
|
||||||
|
|
||||||
if (logoLimit == 0 && artLimit == 0 && thumbLimit == 0 && backdropLimit == 0)
|
if (logoLimit == 0 && artLimit == 0 && thumbLimit == 0 && backdropLimit == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1515,6 +1523,12 @@ namespace Emby.Server.Implementations.Dto
|
||||||
}
|
}
|
||||||
|
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
|
|
||||||
|
if (!parent.SupportsInheritedParentImages)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
parent = parent.GetParent();
|
parent = parent.GetParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,11 +339,6 @@ namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("item");
|
throw new ArgumentNullException("item");
|
||||||
}
|
}
|
||||||
RegisterItem(item.Id, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RegisterItem(Guid id, BaseItem item)
|
|
||||||
{
|
|
||||||
if (item is IItemByName)
|
if (item is IItemByName)
|
||||||
{
|
{
|
||||||
if (!(item is MusicArtist))
|
if (!(item is MusicArtist))
|
||||||
|
@ -354,13 +349,13 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
if (item.IsFolder)
|
if (item.IsFolder)
|
||||||
{
|
{
|
||||||
if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel) && !(item is AggregateFolder))
|
//if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel) && !(item is AggregateFolder))
|
||||||
{
|
//{
|
||||||
if (item.SourceType != SourceType.Library)
|
// if (item.SourceType != SourceType.Library)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -370,7 +365,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LibraryItemsCache.AddOrUpdate(id, item, delegate { return item; });
|
LibraryItemsCache.AddOrUpdate(item.Id, item, delegate { return item; });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteItem(BaseItem item, DeleteOptions options)
|
public async Task DeleteItem(BaseItem item, DeleteOptions options)
|
||||||
|
@ -1273,10 +1268,8 @@ namespace Emby.Server.Implementations.Library
|
||||||
return ItemRepository.GetItemList(query);
|
return ItemRepository.GetItemList(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, IEnumerable<string> parentIds)
|
public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents)
|
||||||
{
|
{
|
||||||
var parents = parentIds.Select(i => GetItemById(new Guid(i))).Where(i => i != null).ToList();
|
|
||||||
|
|
||||||
SetTopParentIdsOrAncestors(query, parents);
|
SetTopParentIdsOrAncestors(query, parents);
|
||||||
|
|
||||||
if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
|
if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
|
||||||
|
@ -1536,7 +1529,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle grouping
|
// Handle grouping
|
||||||
if (user != null && !string.IsNullOrWhiteSpace(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType))
|
if (user != null && !string.IsNullOrWhiteSpace(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType) && user.Configuration.GroupedFolders.Length > 0)
|
||||||
{
|
{
|
||||||
return user.RootFolder
|
return user.RootFolder
|
||||||
.GetChildren(user, true)
|
.GetChildren(user, true)
|
||||||
|
|
|
@ -245,20 +245,26 @@ namespace Emby.Server.Implementations.Library
|
||||||
var includeItemTypes = request.IncludeItemTypes;
|
var includeItemTypes = request.IncludeItemTypes;
|
||||||
var limit = request.Limit ?? 10;
|
var limit = request.Limit ?? 10;
|
||||||
|
|
||||||
var parentIds = string.IsNullOrEmpty(parentId)
|
var parents = new List<BaseItem>();
|
||||||
? new string[] { }
|
|
||||||
: new[] { parentId };
|
|
||||||
|
|
||||||
if (parentIds.Length == 0)
|
if (!string.IsNullOrWhiteSpace(parentId))
|
||||||
{
|
{
|
||||||
parentIds = user.RootFolder.GetChildren(user, true)
|
var parent = _libraryManager.GetItemById(parentId) as Folder;
|
||||||
.OfType<Folder>()
|
if (parent != null)
|
||||||
.Select(i => i.Id.ToString("N"))
|
{
|
||||||
.Where(i => !user.Configuration.LatestItemsExcludes.Contains(i))
|
parents.Add(parent);
|
||||||
.ToArray();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentIds.Length == 0)
|
if (parents.Count == 0)
|
||||||
|
{
|
||||||
|
parents = user.RootFolder.GetChildren(user, true)
|
||||||
|
.Where(i => i is Folder)
|
||||||
|
.Where(i => !user.Configuration.LatestItemsExcludes.Contains(i.Id.ToString("N")))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parents.Count == 0)
|
||||||
{
|
{
|
||||||
return new List<BaseItem>();
|
return new List<BaseItem>();
|
||||||
}
|
}
|
||||||
|
@ -283,10 +289,10 @@ namespace Emby.Server.Implementations.Library
|
||||||
ExcludeItemTypes = excludeItemTypes,
|
ExcludeItemTypes = excludeItemTypes,
|
||||||
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
||||||
Limit = limit * 5,
|
Limit = limit * 5,
|
||||||
SourceTypes = parentIds.Length == 0 ? new[] { SourceType.Library } : new SourceType[] { },
|
SourceTypes = parents.Count == 0 ? new[] { SourceType.Library } : new SourceType[] { },
|
||||||
IsPlayed = request.IsPlayed
|
IsPlayed = request.IsPlayed
|
||||||
|
|
||||||
}, parentIds);
|
}, parents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
|
|
||||||
var id = _tvDtoService.GetInternalChannelId(serviceName, channelInfo.Id);
|
var id = _tvDtoService.GetInternalChannelId(serviceName, channelInfo.Id);
|
||||||
|
|
||||||
var item = _itemRepo.RetrieveItem(id) as LiveTvChannel;
|
var item = _libraryManager.GetItemById(id) as LiveTvChannel;
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,15 @@ namespace Emby.Server.Implementations.Notifications
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT NULL, Url TEXT NULL, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT NULL, PRIMARY KEY (Id, UserId))",
|
"create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT NULL, Url TEXT NULL, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT NULL, PRIMARY KEY (Id, UserId))",
|
||||||
"create index if not exists idx_Notifications1 on Notifications(Id)",
|
"create index if not exists idx_Notifications1 on Notifications(Id)",
|
||||||
"create index if not exists idx_Notifications2 on Notifications(UserId)"
|
"create index if not exists idx_Notifications2 on Notifications(UserId)"
|
||||||
|
@ -48,9 +56,9 @@ namespace Emby.Server.Implementations.Notifications
|
||||||
{
|
{
|
||||||
var result = new NotificationResult();
|
var result = new NotificationResult();
|
||||||
|
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
//using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
var clauses = new List<string>();
|
||||||
var paramList = new List<object>();
|
var paramList = new List<object>();
|
||||||
|
@ -103,9 +111,9 @@ namespace Emby.Server.Implementations.Notifications
|
||||||
{
|
{
|
||||||
var result = new NotificationsSummary();
|
var result = new NotificationsSummary();
|
||||||
|
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
//using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
using (var statement = connection.PrepareStatement("select Level from Notifications where UserId=@UserId and IsRead=@IsRead"))
|
using (var statement = connection.PrepareStatement("select Level from Notifications where UserId=@UserId and IsRead=@IsRead"))
|
||||||
{
|
{
|
||||||
|
@ -220,9 +228,9 @@ namespace Emby.Server.Implementations.Notifications
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(conn =>
|
connection.RunInTransaction(conn =>
|
||||||
{
|
{
|
||||||
|
@ -283,9 +291,9 @@ namespace Emby.Server.Implementations.Notifications
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(conn =>
|
connection.RunInTransaction(conn =>
|
||||||
{
|
{
|
||||||
|
@ -305,9 +313,9 @@ namespace Emby.Server.Implementations.Notifications
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(conn =>
|
connection.RunInTransaction(conn =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,9 +30,16 @@ namespace Emby.Server.Implementations.Security
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
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)"
|
"create index if not exists idx_AccessTokens on AccessTokens(Id)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,9 +70,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 =>
|
||||||
{
|
{
|
||||||
|
@ -200,28 +207,31 @@ namespace Emby.Server.Implementations.Security
|
||||||
|
|
||||||
var list = new List<AuthenticationInfo>();
|
var list = new List<AuthenticationInfo>();
|
||||||
|
|
||||||
using (var statement = connection.PrepareStatement(commandText))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
BindAuthenticationQueryParams(query, statement);
|
using (var statement = connection.PrepareStatement(commandText))
|
||||||
|
|
||||||
foreach (var row in statement.ExecuteQuery())
|
|
||||||
{
|
{
|
||||||
list.Add(Get(row));
|
BindAuthenticationQueryParams(query, statement);
|
||||||
}
|
|
||||||
|
|
||||||
using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging))
|
foreach (var row in statement.ExecuteQuery())
|
||||||
{
|
|
||||||
BindAuthenticationQueryParams(query, totalCountStatement);
|
|
||||||
|
|
||||||
var count = totalCountStatement.ExecuteQuery()
|
|
||||||
.SelectScalarInt()
|
|
||||||
.First();
|
|
||||||
|
|
||||||
return new QueryResult<AuthenticationInfo>()
|
|
||||||
{
|
{
|
||||||
Items = list.ToArray(),
|
list.Add(Get(row));
|
||||||
TotalRecordCount = count
|
}
|
||||||
};
|
|
||||||
|
using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging))
|
||||||
|
{
|
||||||
|
BindAuthenticationQueryParams(query, totalCountStatement);
|
||||||
|
|
||||||
|
var count = totalCountStatement.ExecuteQuery()
|
||||||
|
.SelectScalarInt()
|
||||||
|
.First();
|
||||||
|
|
||||||
|
return new QueryResult<AuthenticationInfo>()
|
||||||
|
{
|
||||||
|
Items = list.ToArray(),
|
||||||
|
TotalRecordCount = count
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,9 +244,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";
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,13 @@ namespace Emby.Server.Implementations.Social
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists Shares (Id GUID, ItemId TEXT, UserId TEXT, ExpirationDate DateTime, PRIMARY KEY (Id))",
|
"create table if not exists Shares (Id GUID, ItemId TEXT, UserId TEXT, ExpirationDate DateTime, PRIMARY KEY (Id))",
|
||||||
|
@ -50,9 +57,9 @@ namespace Emby.Server.Implementations.Social
|
||||||
throw new ArgumentNullException("info.Id");
|
throw new ArgumentNullException("info.Id");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(db =>
|
connection.RunInTransaction(db =>
|
||||||
{
|
{
|
||||||
|
@ -75,9 +82,9 @@ namespace Emby.Server.Implementations.Social
|
||||||
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 = "select Id, ItemId, UserId, ExpirationDate from Shares where id = ?";
|
var commandText = "select Id, ItemId, UserId, ExpirationDate from Shares where id = ?";
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,13 @@ namespace Emby.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
connection.ExecuteAll(string.Join(";", new[]
|
||||||
|
{
|
||||||
|
"PRAGMA page_size=4096",
|
||||||
|
"pragma default_temp_store = memory",
|
||||||
|
"pragma temp_store = memory"
|
||||||
|
}));
|
||||||
|
|
||||||
string[] queries = {
|
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)",
|
"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 +102,9 @@ namespace Emby.Server.Implementations.Sync
|
||||||
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 = BaseJobSelectText + " where Id=?";
|
var commandText = BaseJobSelectText + " where Id=?";
|
||||||
var paramList = new List<object>();
|
var paramList = new List<object>();
|
||||||
|
@ -206,9 +213,9 @@ namespace Emby.Server.Implementations.Sync
|
||||||
|
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
string commandText;
|
string commandText;
|
||||||
var paramList = new List<object>();
|
var paramList = new List<object>();
|
||||||
|
@ -259,9 +266,9 @@ namespace Emby.Server.Implementations.Sync
|
||||||
|
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
connection.RunInTransaction(conn =>
|
connection.RunInTransaction(conn =>
|
||||||
{
|
{
|
||||||
|
@ -281,9 +288,9 @@ namespace Emby.Server.Implementations.Sync
|
||||||
|
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
using (WriteLock.Read())
|
using (var connection = CreateConnection(true))
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection(true))
|
using (WriteLock.Read())
|
||||||
{
|
{
|
||||||
var commandText = BaseJobSelectText;
|
var commandText = BaseJobSelectText;
|
||||||
var paramList = new List<object>();
|
var paramList = new List<object>();
|
||||||
|
@ -379,11 +386,11 @@ namespace Emby.Server.Implementations.Sync
|
||||||
|
|
||||||
CheckDisposed();
|
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 commandText = BaseJobItemSelectText + " where Id=?";
|
||||||
var paramList = new List<object>();
|
var paramList = new List<object>();
|
||||||
|
@ -407,9 +414,9 @@ namespace Emby.Server.Implementations.Sync
|
||||||
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;
|
||||||
var paramList = new List<object>();
|
var paramList = new List<object>();
|
||||||
|
@ -487,30 +494,30 @@ namespace Emby.Server.Implementations.Sync
|
||||||
|
|
||||||
var now = DateTime.UtcNow;
|
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>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(query.TargetId))
|
||||||
{
|
{
|
||||||
var commandText = "select ItemId,Status,Progress from SyncJobItems";
|
whereClauses.Add("TargetId=@TargetId");
|
||||||
var whereClauses = new List<string>();
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(query.TargetId))
|
if (query.Statuses.Length > 0)
|
||||||
{
|
{
|
||||||
whereClauses.Add("TargetId=@TargetId");
|
var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray());
|
||||||
}
|
|
||||||
|
|
||||||
if (query.Statuses.Length > 0)
|
whereClauses.Add(string.Format("Status in ({0})", statuses));
|
||||||
{
|
}
|
||||||
var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray());
|
|
||||||
|
|
||||||
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))
|
using (var statement = connection.PrepareStatement(commandText))
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(query.TargetId))
|
if (!string.IsNullOrWhiteSpace(query.TargetId))
|
||||||
|
@ -664,9 +671,9 @@ namespace Emby.Server.Implementations.Sync
|
||||||
|
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
using (WriteLock.Write())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (WriteLock.Write())
|
||||||
{
|
{
|
||||||
string commandText;
|
string commandText;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
return GetResult(episodes, null, request);
|
return GetResult(episodes, null, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryResult<BaseItem> GetNextUp(NextUpQuery request, IEnumerable<Folder> parentsFolders)
|
public QueryResult<BaseItem> GetNextUp(NextUpQuery request, List<Folder> parentsFolders)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = _userManager.GetUserById(request.UserId);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
PresentationUniqueKey = presentationUniqueKey,
|
PresentationUniqueKey = presentationUniqueKey,
|
||||||
Limit = limit
|
Limit = limit
|
||||||
|
|
||||||
}, parentsFolders.Select(i => i.Id.ToString("N"))).Cast<Series>();
|
}, parentsFolders.Cast<BaseItem>().ToList()).Cast<Series>();
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
var episodes = GetNextUpEpisodes(request, user, items);
|
var episodes = GetNextUpEpisodes(request, user, items);
|
||||||
|
@ -121,17 +121,15 @@ namespace Emby.Server.Implementations.TV
|
||||||
|
|
||||||
var allNextUp = series
|
var allNextUp = series
|
||||||
.Select(i => GetNextUp(i, currentUser))
|
.Select(i => GetNextUp(i, currentUser))
|
||||||
.Where(i => i.Item1 != null)
|
|
||||||
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
|
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
|
||||||
.OrderByDescending(i => i.Item2)
|
.OrderByDescending(i => i.Item1)
|
||||||
.ThenByDescending(i => i.Item1.PremiereDate ?? DateTime.MinValue)
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// If viewing all next up for all series, remove first episodes
|
// If viewing all next up for all series, remove first episodes
|
||||||
if (string.IsNullOrWhiteSpace(request.SeriesId))
|
if (string.IsNullOrWhiteSpace(request.SeriesId))
|
||||||
{
|
{
|
||||||
var withoutFirstEpisode = allNextUp
|
var withoutFirstEpisode = allNextUp
|
||||||
.Where(i => !i.Item3)
|
.Where(i => i.Item1 != DateTime.MinValue)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// But if that returns empty, keep those first episodes (avoid completely empty view)
|
// But if that returns empty, keep those first episodes (avoid completely empty view)
|
||||||
|
@ -142,7 +140,8 @@ namespace Emby.Server.Implementations.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
return allNextUp
|
return allNextUp
|
||||||
.Select(i => i.Item1)
|
.Select(i => i.Item2())
|
||||||
|
.Where(i => i != null)
|
||||||
.Take(request.Limit ?? int.MaxValue);
|
.Take(request.Limit ?? int.MaxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
/// <param name="series">The series.</param>
|
/// <param name="series">The series.</param>
|
||||||
/// <param name="user">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
/// <returns>Task{Episode}.</returns>
|
/// <returns>Task{Episode}.</returns>
|
||||||
private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user)
|
private Tuple<DateTime, Func<Episode>> GetNextUp(Series series, User user)
|
||||||
{
|
{
|
||||||
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
|
@ -171,31 +170,34 @@ namespace Emby.Server.Implementations.TV
|
||||||
|
|
||||||
}).FirstOrDefault();
|
}).FirstOrDefault();
|
||||||
|
|
||||||
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
Func<Episode> getEpisode = () =>
|
||||||
{
|
{
|
||||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
|
return _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
{
|
||||||
SortBy = new[] { ItemSortBy.SortName },
|
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
|
||||||
SortOrder = SortOrder.Ascending,
|
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||||
Limit = 1,
|
SortBy = new[] { ItemSortBy.SortName },
|
||||||
IsPlayed = false,
|
SortOrder = SortOrder.Ascending,
|
||||||
IsVirtualItem = false,
|
Limit = 1,
|
||||||
ParentIndexNumberNotEquals = 0,
|
IsPlayed = false,
|
||||||
MinSortName = lastWatchedEpisode == null ? null : lastWatchedEpisode.SortName
|
IsVirtualItem = false,
|
||||||
|
ParentIndexNumberNotEquals = 0,
|
||||||
|
MinSortName = lastWatchedEpisode == null ? null : lastWatchedEpisode.SortName
|
||||||
|
|
||||||
}).Cast<Episode>().FirstOrDefault();
|
}).Cast<Episode>().FirstOrDefault();
|
||||||
|
};
|
||||||
|
|
||||||
if (lastWatchedEpisode != null && firstUnwatchedEpisode != null)
|
if (lastWatchedEpisode != null)
|
||||||
{
|
{
|
||||||
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
|
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
|
||||||
|
|
||||||
var lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
var lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
||||||
|
|
||||||
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, lastWatchedDate, false);
|
return new Tuple<DateTime, Func<Episode>>(lastWatchedDate, getEpisode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the first episode
|
// Return the first episode
|
||||||
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, DateTime.MinValue, true);
|
return new Tuple<DateTime, Func<Episode>>(DateTime.MinValue, getEpisode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, int? totalRecordLimit, NextUpQuery query)
|
private QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, int? totalRecordLimit, NextUpQuery query)
|
||||||
|
|
|
@ -369,7 +369,7 @@ namespace MediaBrowser.Api.Library
|
||||||
|
|
||||||
if (item is Movie || (program != null && program.IsMovie) || item is Trailer)
|
if (item is Movie || (program != null && program.IsMovie) || item is Trailer)
|
||||||
{
|
{
|
||||||
return new MoviesService(_userManager, _userDataManager, _libraryManager, _itemRepo, _dtoService, _config, _authContext)
|
return new MoviesService(_userManager, _libraryManager, _dtoService, _config, _authContext)
|
||||||
{
|
{
|
||||||
Request = Request,
|
Request = Request,
|
||||||
|
|
||||||
|
|
|
@ -78,16 +78,8 @@ namespace MediaBrowser.Api.Movies
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _user data repository
|
|
||||||
/// </summary>
|
|
||||||
private readonly IUserDataManager _userDataRepository;
|
|
||||||
/// <summary>
|
|
||||||
/// The _library manager
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
private readonly IItemRepository _itemRepo;
|
|
||||||
private readonly IDtoService _dtoService;
|
private readonly IDtoService _dtoService;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IAuthorizationContext _authContext;
|
private readonly IAuthorizationContext _authContext;
|
||||||
|
@ -95,17 +87,10 @@ namespace MediaBrowser.Api.Movies
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MoviesService" /> class.
|
/// Initializes a new instance of the <see cref="MoviesService" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userManager">The user manager.</param>
|
public MoviesService(IUserManager userManager, ILibraryManager libraryManager, IDtoService dtoService, IServerConfigurationManager config, IAuthorizationContext authContext)
|
||||||
/// <param name="userDataRepository">The user data repository.</param>
|
|
||||||
/// <param name="libraryManager">The library manager.</param>
|
|
||||||
/// <param name="itemRepo">The item repo.</param>
|
|
||||||
/// <param name="dtoService">The dto service.</param>
|
|
||||||
public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService, IServerConfigurationManager config, IAuthorizationContext authContext)
|
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_userDataRepository = userDataRepository;
|
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_itemRepo = itemRepo;
|
|
||||||
_dtoService = dtoService;
|
_dtoService = dtoService;
|
||||||
_config = config;
|
_config = config;
|
||||||
_authContext = authContext;
|
_authContext = authContext;
|
||||||
|
|
|
@ -61,6 +61,12 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public override bool SupportsInheritedParentImages
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
protected override bool SupportsOwnedItems
|
protected override bool SupportsOwnedItems
|
||||||
{
|
{
|
||||||
|
|
|
@ -1569,6 +1569,12 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return IsVisibleStandaloneInternal(user, true);
|
return IsVisibleStandaloneInternal(user, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public virtual bool SupportsInheritedParentImages
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
|
protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
|
||||||
{
|
{
|
||||||
if (!IsVisible(user))
|
if (!IsVisible(user))
|
||||||
|
@ -2329,17 +2335,25 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (GetParent() is AggregateFolder || this is BasePluginFolder || this is Channel)
|
if (this is BasePluginFolder || this is Channel)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var view = this as UserView;
|
var view = this as UserView;
|
||||||
if (view != null && string.Equals(view.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
|
if (view != null)
|
||||||
{
|
{
|
||||||
return true;
|
if (string.Equals(view.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (string.Equals(view.ViewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (view != null && string.Equals(view.ViewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase))
|
|
||||||
|
if (GetParent() is AggregateFolder)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1383,6 +1383,15 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
var iItemByName = this as IItemByName;
|
||||||
|
if (iItemByName != null)
|
||||||
|
{
|
||||||
|
var hasDualAccess = this as IHasDualAccess;
|
||||||
|
if (hasDualAccess == null || hasDualAccess.IsAccessedByName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1395,17 +1404,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var unplayedQueryResult = await GetItems(new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
Recursive = true,
|
|
||||||
IsFolder = false,
|
|
||||||
IsVirtualItem = false,
|
|
||||||
EnableTotalRecordCount = true,
|
|
||||||
Limit = 0,
|
|
||||||
IsPlayed = false
|
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var allItemsQueryResult = await GetItems(new InternalItemsQuery(user)
|
var allItemsQueryResult = await GetItems(new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
Recursive = true,
|
Recursive = true,
|
||||||
|
@ -1415,17 +1413,28 @@ namespace MediaBrowser.Controller.Entities
|
||||||
Limit = 0
|
Limit = 0
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
var recursiveItemCount = allItemsQueryResult.TotalRecordCount;
|
||||||
|
|
||||||
if (itemDto != null)
|
if (itemDto != null)
|
||||||
{
|
{
|
||||||
itemDto.RecursiveItemCount = allItemsQueryResult.TotalRecordCount;
|
itemDto.RecursiveItemCount = allItemsQueryResult.TotalRecordCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
var recursiveItemCount = allItemsQueryResult.TotalRecordCount;
|
if (recursiveItemCount > 0 && SupportsPlayedStatus)
|
||||||
double unplayedCount = unplayedQueryResult.TotalRecordCount;
|
|
||||||
|
|
||||||
if (recursiveItemCount > 0)
|
|
||||||
{
|
{
|
||||||
|
var unplayedQueryResult = recursiveItemCount > 0 ? await GetItems(new InternalItemsQuery(user)
|
||||||
|
{
|
||||||
|
Recursive = true,
|
||||||
|
IsFolder = false,
|
||||||
|
IsVirtualItem = false,
|
||||||
|
EnableTotalRecordCount = true,
|
||||||
|
Limit = 0,
|
||||||
|
IsPlayed = false
|
||||||
|
|
||||||
|
}).ConfigureAwait(false) : new QueryResult<BaseItem>();
|
||||||
|
|
||||||
|
double unplayedCount = unplayedQueryResult.TotalRecordCount;
|
||||||
|
|
||||||
var unplayedPercentage = (unplayedCount / recursiveItemCount) * 100;
|
var unplayedPercentage = (unplayedCount / recursiveItemCount) * 100;
|
||||||
dto.PlayedPercentage = 100 - unplayedPercentage;
|
dto.PlayedPercentage = 100 - unplayedPercentage;
|
||||||
dto.Played = dto.PlayedPercentage.Value >= 100;
|
dto.Played = dto.PlayedPercentage.Value >= 100;
|
||||||
|
|
|
@ -124,7 +124,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public int? MaxParentalRating { get; set; }
|
public int? MaxParentalRating { get; set; }
|
||||||
|
|
||||||
public bool? HasDeadParentId { get; set; }
|
public bool? HasDeadParentId { get; set; }
|
||||||
public bool? IsOffline { get; set; }
|
|
||||||
public bool? IsVirtualItem { get; set; }
|
public bool? IsVirtualItem { get; set; }
|
||||||
|
|
||||||
public Guid? ParentId { get; set; }
|
public Guid? ParentId { get; set; }
|
||||||
|
|
|
@ -73,6 +73,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public override bool SupportsInheritedParentImages
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public int? AiredSeasonNumber
|
public int? AiredSeasonNumber
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public override bool SupportsInheritedParentImages
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public override Guid? DisplayParentId
|
public override Guid? DisplayParentId
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,7 +135,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
{
|
{
|
||||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
||||||
IncludeItemTypes = new[] { typeof(Season).Name },
|
IncludeItemTypes = new[] { typeof(Season).Name },
|
||||||
SortBy = new[] { ItemSortBy.SortName },
|
|
||||||
IsVirtualItem = false,
|
IsVirtualItem = false,
|
||||||
Limit = 0
|
Limit = 0
|
||||||
});
|
});
|
||||||
|
|
|
@ -1812,7 +1812,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
.Where(i => user.IsFolderGrouped(i.Id) && UserView.IsEligibleForGrouping(i));
|
.Where(i => user.IsFolderGrouped(i.Id) && UserView.IsEligibleForGrouping(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Folder> GetMediaFolders(User user, IEnumerable<string> viewTypes)
|
private List<Folder> GetMediaFolders(User user, IEnumerable<string> viewTypes)
|
||||||
{
|
{
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
|
@ -1822,7 +1822,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
var folder = i as ICollectionFolder;
|
var folder = i as ICollectionFolder;
|
||||||
|
|
||||||
return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
||||||
});
|
}).ToList();
|
||||||
}
|
}
|
||||||
return GetMediaFolders(user)
|
return GetMediaFolders(user)
|
||||||
.Where(i =>
|
.Where(i =>
|
||||||
|
@ -1830,17 +1830,17 @@ namespace MediaBrowser.Controller.Entities
|
||||||
var folder = i as ICollectionFolder;
|
var folder = i as ICollectionFolder;
|
||||||
|
|
||||||
return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
||||||
});
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Folder> GetMediaFolders(Folder parent, User user, IEnumerable<string> viewTypes)
|
private List<Folder> GetMediaFolders(Folder parent, User user, IEnumerable<string> viewTypes)
|
||||||
{
|
{
|
||||||
if (parent == null || parent is UserView)
|
if (parent == null || parent is UserView)
|
||||||
{
|
{
|
||||||
return GetMediaFolders(user, viewTypes);
|
return GetMediaFolders(user, viewTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new[] { parent };
|
return new List<Folder> { parent };
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<BaseItem> GetRecursiveChildren(Folder parent, User user, IEnumerable<string> viewTypes)
|
private IEnumerable<BaseItem> GetRecursiveChildren(Folder parent, User user, IEnumerable<string> viewTypes)
|
||||||
|
|
|
@ -538,10 +538,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the items.
|
/// Gets the items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query">The query.</param>
|
IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents);
|
||||||
/// <param name="parentIds">The parent ids.</param>
|
|
||||||
/// <returns>List<BaseItem>.</returns>
|
|
||||||
IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, IEnumerable<string> parentIds);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the items result.
|
/// Gets the items result.
|
||||||
|
|
|
@ -19,6 +19,6 @@ namespace MediaBrowser.Controller.TV
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="parentsFolders">The parents folders.</param>
|
/// <param name="parentsFolders">The parents folders.</param>
|
||||||
/// <returns>QueryResult<BaseItem>.</returns>
|
/// <returns>QueryResult<BaseItem>.</returns>
|
||||||
QueryResult<BaseItem> GetNextUp(NextUpQuery request, IEnumerable<Folder> parentsFolders);
|
QueryResult<BaseItem> GetNextUp(NextUpQuery request, List<Folder> parentsFolders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace MediaBrowser.Model.System
|
||||||
Architecture SystemArchitecture { get; }
|
Architecture SystemArchitecture { get; }
|
||||||
string GetEnvironmentVariable(string name);
|
string GetEnvironmentVariable(string name);
|
||||||
string GetUserId();
|
string GetUserId();
|
||||||
|
string StackTrace { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OperatingSystem
|
public enum OperatingSystem
|
||||||
|
|
|
@ -536,7 +536,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
|
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
|
||||||
|
|
||||||
// Only one local provider allowed per item
|
// Only one local provider allowed per item
|
||||||
if (item.IsLocked || IsFullLocalMetadata(localItem.Item))
|
if (item.IsLocked || localItem.Item.IsLocked || IsFullLocalMetadata(localItem.Item))
|
||||||
{
|
{
|
||||||
hasLocalMetadata = true;
|
hasLocalMetadata = true;
|
||||||
}
|
}
|
||||||
|
@ -573,14 +573,16 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
if (refreshResult.UpdateType > ItemUpdateType.None)
|
if (refreshResult.UpdateType > ItemUpdateType.None)
|
||||||
{
|
{
|
||||||
// If no local metadata, take data from item itself
|
if (hasLocalMetadata)
|
||||||
if (!hasLocalMetadata)
|
{
|
||||||
|
MergeData(temp, metadata, item.LockedFields, true, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields
|
// TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields
|
||||||
MergeData(metadata, temp, new List<MetadataFields>(), false, true);
|
MergeData(metadata, temp, new List<MetadataFields>(), false, false);
|
||||||
|
MergeData(temp, metadata, item.LockedFields, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeData(temp, metadata, item.LockedFields, true, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user