mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
Address comments
This commit is contained in:
parent
2e4c0fee77
commit
45c13141f9
@ -36,9 +36,9 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
protected virtual SynchronousMode? Synchronous => null;
|
protected virtual SynchronousMode? Synchronous => null;
|
||||||
|
|
||||||
protected SemaphoreSlim WriteLock = new SemaphoreSlim(1, 1);
|
protected SemaphoreSlim WriteLock { get; set; } = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
protected SQLiteDatabaseConnection WriteConnection;
|
protected SQLiteDatabaseConnection WriteConnection { get; set; }
|
||||||
|
|
||||||
protected ManagedConnection GetConnection(bool _ = false)
|
protected ManagedConnection GetConnection(bool _ = false)
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (CacheSize.HasValue)
|
if (CacheSize.HasValue)
|
||||||
{
|
{
|
||||||
WriteConnection.Execute("PRAGMA cache_size=" + (int)CacheSize.Value);
|
WriteConnection.Execute("PRAGMA cache_size=" + CacheSize.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(JournalMode))
|
if (!string.IsNullOrWhiteSpace(JournalMode))
|
||||||
@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (PageSize.HasValue)
|
if (PageSize.HasValue)
|
||||||
{
|
{
|
||||||
WriteConnection.Execute("PRAGMA page_size=" + (int)PageSize.Value);
|
WriteConnection.Execute("PRAGMA page_size=" + PageSize.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteConnection.Execute("PRAGMA temp_store=" + (int)TempStore);
|
WriteConnection.Execute("PRAGMA temp_store=" + (int)TempStore);
|
||||||
@ -109,7 +109,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
protected List<string> GetColumnNames(IDatabaseConnection connection, string table)
|
protected List<string> GetColumnNames(IDatabaseConnection connection, string table)
|
||||||
{
|
{
|
||||||
var list = new List<string>();
|
var columnNames = new List<string>();
|
||||||
|
|
||||||
foreach (var row in connection.Query("PRAGMA table_info(" + table + ")"))
|
foreach (var row in connection.Query("PRAGMA table_info(" + table + ")"))
|
||||||
{
|
{
|
||||||
@ -117,11 +117,11 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
var name = row[1].ToString();
|
var name = row[1].ToString();
|
||||||
|
|
||||||
list.Add(name);
|
columnNames.Add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return columnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddColumn(IDatabaseConnection connection, string table, string columnName, string type, List<string> existingColumnNames)
|
protected void AddColumn(IDatabaseConnection connection, string table, string columnName, string type, List<string> existingColumnNames)
|
||||||
@ -142,6 +142,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -36,13 +36,9 @@ namespace Emby.Server.Implementations.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SqliteItemRepository : BaseSqliteRepository, IItemRepository
|
public class SqliteItemRepository : BaseSqliteRepository, IItemRepository
|
||||||
{
|
{
|
||||||
private readonly TypeMapper _typeMapper;
|
private const string ChaptersTableName = "Chapters2";
|
||||||
|
|
||||||
/// <summary>
|
private readonly TypeMapper _typeMapper;
|
||||||
/// Gets the name of the repository
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The name.</value>
|
|
||||||
public string Name => "SQLite";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the json serializer.
|
/// Gets the json serializer.
|
||||||
@ -54,12 +50,9 @@ namespace Emby.Server.Implementations.Data
|
|||||||
/// The _app paths
|
/// The _app paths
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
|
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
|
|
||||||
public IImageProcessor ImageProcessor { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -90,10 +83,17 @@ namespace Emby.Server.Implementations.Data
|
|||||||
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
|
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string ChaptersTableName = "Chapters2";
|
/// <inheritdoc />
|
||||||
|
public string Name => "SQLite";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override int? CacheSize => 20000;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
protected override TempStoreMode TempStore => TempStoreMode.Memory;
|
protected override TempStoreMode TempStore => TempStoreMode.Memory;
|
||||||
|
|
||||||
|
public IImageProcessor ImageProcessor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the connection to the database
|
/// Opens the connection to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1903,7 +1903,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
using (var connection = GetConnection(true))
|
using (var connection = GetConnection(true))
|
||||||
{
|
{
|
||||||
var list = new List<ChapterInfo>();
|
var chapters = new List<ChapterInfo>();
|
||||||
|
|
||||||
using (var statement = PrepareStatement(connection, "select StartPositionTicks,Name,ImagePath,ImageDateModified from " + ChaptersTableName + " where ItemId = @ItemId order by ChapterIndex asc"))
|
using (var statement = PrepareStatement(connection, "select StartPositionTicks,Name,ImagePath,ImageDateModified from " + ChaptersTableName + " where ItemId = @ItemId order by ChapterIndex asc"))
|
||||||
{
|
{
|
||||||
@ -1911,11 +1911,11 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
foreach (var row in statement.ExecuteQuery())
|
foreach (var row in statement.ExecuteQuery())
|
||||||
{
|
{
|
||||||
list.Add(GetChapter(row, item));
|
chapters.Add(GetChapter(row, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return chapters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2606,7 +2606,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
using (var connection = GetConnection(true))
|
using (var connection = GetConnection(true))
|
||||||
{
|
{
|
||||||
var list = new List<BaseItem>();
|
var items = new List<BaseItem>();
|
||||||
|
|
||||||
using (var statement = PrepareStatement(connection, commandText))
|
using (var statement = PrepareStatement(connection, commandText))
|
||||||
{
|
{
|
||||||
@ -2634,7 +2634,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
|
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
list.Add(item);
|
items.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2646,7 +2646,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
limit -= 4;
|
limit -= 4;
|
||||||
var newList = new List<BaseItem>();
|
var newList = new List<BaseItem>();
|
||||||
|
|
||||||
foreach (var item in list)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
AddItem(newList, item);
|
AddItem(newList, item);
|
||||||
|
|
||||||
@ -2656,12 +2656,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list = newList;
|
items = newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogQueryTime("GetItemList", commandText, now);
|
LogQueryTime("GetItemList", commandText, now);
|
||||||
|
|
||||||
return list;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user