mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
show more music favorites
This commit is contained in:
parent
7760f022af
commit
f9e9f5bef6
@ -17,12 +17,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Sync
|
||||
{
|
||||
public class SyncRepository : ISyncRepository, IDisposable
|
||||
public class SyncRepository : BaseSqliteRepository, ISyncRepository
|
||||
{
|
||||
private IDbConnection _connection;
|
||||
private readonly ILogger _logger;
|
||||
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
private IDbCommand _insertJobCommand;
|
||||
@ -34,19 +31,20 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
private IDbCommand _updateJobItemCommand;
|
||||
|
||||
private readonly IJsonSerializer _json;
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
|
||||
public SyncRepository(ILogger logger, IServerApplicationPaths appPaths, IJsonSerializer json)
|
||||
public SyncRepository(ILogManager logManager, IJsonSerializer json, IServerApplicationPaths appPaths)
|
||||
: base(logManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_appPaths = appPaths;
|
||||
_json = json;
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "sync14.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
@ -62,10 +60,10 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, _logger);
|
||||
_connection.RunQueries(queries, Logger);
|
||||
|
||||
_connection.AddColumn(_logger, "SyncJobs", "Profile", "TEXT");
|
||||
_connection.AddColumn(_logger, "SyncJobs", "Bitrate", "INT");
|
||||
_connection.AddColumn(Logger, "SyncJobs", "Profile", "TEXT");
|
||||
_connection.AddColumn(Logger, "SyncJobs", "Bitrate", "INT");
|
||||
|
||||
PrepareStatements();
|
||||
}
|
||||
@ -298,7 +296,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
await _writeLock.WaitAsync().ConfigureAwait(false);
|
||||
await WriteLock.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
|
||||
@ -344,7 +342,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Failed to save record:", e);
|
||||
Logger.ErrorException("Failed to save record:", e);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
@ -360,7 +358,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
transaction.Dispose();
|
||||
}
|
||||
|
||||
_writeLock.Release();
|
||||
WriteLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,7 +371,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
await _writeLock.WaitAsync().ConfigureAwait(false);
|
||||
await WriteLock.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
|
||||
@ -405,7 +403,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Failed to save record:", e);
|
||||
Logger.ErrorException("Failed to save record:", e);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
@ -421,7 +419,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
transaction.Dispose();
|
||||
}
|
||||
|
||||
_writeLock.Release();
|
||||
WriteLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@ -656,7 +654,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
await _writeLock.WaitAsync().ConfigureAwait(false);
|
||||
await WriteLock.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
|
||||
@ -699,7 +697,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Failed to save record:", e);
|
||||
Logger.ErrorException("Failed to save record:", e);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
@ -715,7 +713,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
transaction.Dispose();
|
||||
}
|
||||
|
||||
_writeLock.Release();
|
||||
WriteLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@ -802,15 +800,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
private void CheckDisposed()
|
||||
{
|
||||
@ -820,38 +809,26 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
}
|
||||
}
|
||||
|
||||
private readonly object _disposeLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool dispose)
|
||||
protected override void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
_disposed = true;
|
||||
}
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
|
||||
try
|
||||
protected override void CloseConnection()
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
if (_connection.IsOpen())
|
||||
{
|
||||
lock (_disposeLock)
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
if (_connection.IsOpen())
|
||||
{
|
||||
_connection.Close();
|
||||
}
|
||||
_connection.Close();
|
||||
}
|
||||
|
||||
_connection.Dispose();
|
||||
_connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error disposing database", ex);
|
||||
}
|
||||
_connection.Dispose();
|
||||
_connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user