fix userdata transactions

pull/702/head
Luke Pulverenti 9 years ago
parent f8dedb3fe8
commit cf0d9883c6

@ -58,7 +58,7 @@ namespace MediaBrowser.Api.Movies
getItems.IncludeItemTypes = "Trailer"; getItems.IncludeItemTypes = "Trailer";
return new ItemsService(_userManager, _libraryManager, _userDataRepository, _localizationManager, _dtoService, _collectionManager) return new ItemsService(_userManager, _libraryManager, _localizationManager, _dtoService)
{ {
AuthorizationContext = AuthorizationContext, AuthorizationContext = AuthorizationContext,
Logger = Logger, Logger = Logger,

@ -842,17 +842,17 @@ namespace MediaBrowser.Model.Dlna
{ {
bool requiresConversion = !StringHelper.EqualsIgnoreCase(subtitleStream.Codec, profile.Format); bool requiresConversion = !StringHelper.EqualsIgnoreCase(subtitleStream.Codec, profile.Format);
if (requiresConversion && !allowConversion) if (!requiresConversion)
{ {
continue; return profile;
} }
if (!requiresConversion) if (!allowConversion)
{ {
return profile; continue;
} }
if (subtitleStream.IsTextSubtitleStream && subtitleStream.SupportsExternalStream) if (subtitleStream.IsTextSubtitleStream && subtitleStream.SupportsExternalStream && subtitleStream.SupportsSubtitleConversionTo(profile.Format))
{ {
return profile; return profile;
} }

@ -282,6 +282,36 @@ namespace MediaBrowser.Model.Entities
!StringHelper.EqualsIgnoreCase(codec, "sub"); !StringHelper.EqualsIgnoreCase(codec, "sub");
} }
public bool SupportsSubtitleConversionTo(string codec)
{
if (!IsTextSubtitleStream)
{
return false;
}
// Can't convert from this
if (StringHelper.EqualsIgnoreCase(Codec, "ass"))
{
return false;
}
if (StringHelper.EqualsIgnoreCase(Codec, "ssa"))
{
return false;
}
// Can't convert to this
if (StringHelper.EqualsIgnoreCase(codec, "ass"))
{
return false;
}
if (StringHelper.EqualsIgnoreCase(codec, "ssa"))
{
return false;
}
return true;
}
/// <summary> /// <summary>
/// Gets or sets a value indicating whether [supports external stream]. /// Gets or sets a value indicating whether [supports external stream].
/// </summary> /// </summary>

@ -69,14 +69,6 @@ namespace MediaBrowser.Server.Implementations.Library
if (stream.IsTextSubtitleStream) if (stream.IsTextSubtitleStream)
{ {
if (string.Equals(stream.Codec, "ass", StringComparison.OrdinalIgnoreCase))
{
return false;
}
if (string.Equals(stream.Codec, "ssa", StringComparison.OrdinalIgnoreCase))
{
return false;
}
return true; return true;
} }

@ -8,7 +8,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
public abstract class BaseSqliteRepository : IDisposable public abstract class BaseSqliteRepository : IDisposable
{ {
protected readonly SemaphoreSlim WriteLock = new SemaphoreSlim(1, 1); protected SemaphoreSlim WriteLock = new SemaphoreSlim(1, 1);
protected readonly IDbConnector DbConnector; protected readonly IDbConnector DbConnector;
protected ILogger Logger; protected ILogger Logger;

@ -328,7 +328,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
new MediaStreamColumns(_connection, Logger).AddColumns(); new MediaStreamColumns(_connection, Logger).AddColumns();
DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb"); DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb");
await userDataRepo.Initialize(_connection).ConfigureAwait(false); await userDataRepo.Initialize(_connection, WriteLock).ConfigureAwait(false);
//await Vacuum(_connection).ConfigureAwait(false); //await Vacuum(_connection).ConfigureAwait(false);
} }

@ -56,8 +56,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// Opens the connection to the database /// Opens the connection to the database
/// </summary> /// </summary>
/// <returns>Task.</returns> /// <returns>Task.</returns>
public async Task Initialize(IDbConnection connection) public async Task Initialize(IDbConnection connection, SemaphoreSlim writeLock)
{ {
WriteLock.Dispose();
WriteLock = writeLock;
_connection = connection; _connection = connection;
string[] queries = { string[] queries = {
@ -438,18 +440,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
return userData; return userData;
} }
protected override void CloseConnection() protected override void Dispose(bool dispose)
{
if (_connection != null)
{
if (_connection.IsOpen())
{ {
_connection.Close(); // handled by library database
} }
_connection.Dispose(); protected override void CloseConnection()
_connection = null; {
} // handled by library database
} }
} }
} }
Loading…
Cancel
Save