mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 13:58:29 +01:00
expose Tmdb collection id in editor.
This commit is contained in:
@@ -44,7 +44,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create index if not exists idx_chapters on chapters(ItemId, ChapterIndex)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
@@ -86,8 +86,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
|
||||
"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)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
@@ -124,18 +124,24 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create index if not exists idx_ChildrenIds on ChildrenIds(ParentId,ItemId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
PrepareStatements();
|
||||
|
||||
|
||||
_mediaStreamsRepository.Initialize();
|
||||
_providerInfoRepository.Initialize();
|
||||
_chapterRepository.Initialize();
|
||||
|
||||
_shrinkMemoryTimer = new SqliteShrinkMemoryTimer(_connection, _writeLock, _logger);
|
||||
}
|
||||
|
||||
private SqliteShrinkMemoryTimer _shrinkMemoryTimer;
|
||||
|
||||
/// <summary>
|
||||
/// The _write lock
|
||||
/// </summary>
|
||||
@@ -402,6 +408,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
lock (_disposeLock)
|
||||
{
|
||||
if (_shrinkMemoryTimer != null)
|
||||
{
|
||||
_shrinkMemoryTimer.Dispose();
|
||||
_shrinkMemoryTimer = null;
|
||||
}
|
||||
|
||||
if (_connection != null)
|
||||
{
|
||||
if (_connection.IsOpen())
|
||||
@@ -412,30 +424,30 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_connection.Dispose();
|
||||
_connection = null;
|
||||
}
|
||||
|
||||
if (_chapterRepository != null)
|
||||
{
|
||||
_chapterRepository.Dispose();
|
||||
_chapterRepository = null;
|
||||
}
|
||||
|
||||
if (_mediaStreamsRepository != null)
|
||||
{
|
||||
_mediaStreamsRepository.Dispose();
|
||||
_mediaStreamsRepository = null;
|
||||
}
|
||||
|
||||
if (_providerInfoRepository != null)
|
||||
{
|
||||
_providerInfoRepository.Dispose();
|
||||
_providerInfoRepository = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error disposing database", ex);
|
||||
}
|
||||
|
||||
if (_chapterRepository != null)
|
||||
{
|
||||
_chapterRepository.Dispose();
|
||||
_chapterRepository = null;
|
||||
}
|
||||
|
||||
if (_mediaStreamsRepository != null)
|
||||
{
|
||||
_mediaStreamsRepository.Dispose();
|
||||
_mediaStreamsRepository = null;
|
||||
}
|
||||
|
||||
if (_providerInfoRepository != null)
|
||||
{
|
||||
_providerInfoRepository.Dispose();
|
||||
_providerInfoRepository = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create index if not exists idx_mediastreams on mediastreams(ItemId, StreamIndex)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
@@ -45,7 +45,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create index if not exists idx_Notifications on Notifications(Id, UserId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
@@ -42,7 +42,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create index if not exists idx_providerinfos on providerinfos(ItemId, ProviderId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
class SqliteShrinkMemoryTimer : IDisposable
|
||||
{
|
||||
private Timer _shrinkMemoryTimer;
|
||||
|
||||
private readonly SemaphoreSlim _writeLock;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDbConnection _connection;
|
||||
|
||||
public SqliteShrinkMemoryTimer(IDbConnection connection, SemaphoreSlim writeLock, ILogger logger)
|
||||
{
|
||||
_connection = connection;
|
||||
_writeLock = writeLock;
|
||||
_logger = logger;
|
||||
|
||||
_shrinkMemoryTimer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(30));
|
||||
}
|
||||
|
||||
private async void TimerCallback(object state)
|
||||
{
|
||||
await _writeLock.WaitAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
|
||||
try
|
||||
{
|
||||
transaction = _connection.BeginTransaction();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.CommandText = "pragma shrink_memory";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Failed to save items:", e);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Dispose();
|
||||
}
|
||||
|
||||
_writeLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_shrinkMemoryTimer != null)
|
||||
{
|
||||
_shrinkMemoryTimer.Dispose();
|
||||
_shrinkMemoryTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create unique index if not exists userdataindex on userdata (key, userId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
@@ -77,8 +77,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create table if not exists users (guid GUID primary key, data BLOB)",
|
||||
"create index if not exists idx_users on users(guid)",
|
||||
"create table if not exists schema_version (table_name primary key, version)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory"
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
|
||||
Reference in New Issue
Block a user