mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
fixes #2904 - disabling transcoding for a user is not working
This commit is contained in:
parent
e5f340d6b7
commit
2d29d903be
@ -10,20 +10,39 @@ using MediaBrowser.Model.Logging;
|
|||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using SQLitePCL.pretty;
|
using SQLitePCL.pretty;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Activity
|
namespace Emby.Server.Implementations.Activity
|
||||||
{
|
{
|
||||||
public class ActivityRepository : BaseSqliteRepository, IActivityRepository
|
public class ActivityRepository : BaseSqliteRepository, IActivityRepository
|
||||||
{
|
{
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
|
protected IFileSystem FileSystem { get; private set; }
|
||||||
|
|
||||||
public ActivityRepository(ILogger logger, IServerApplicationPaths appPaths)
|
public ActivityRepository(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
{
|
{
|
||||||
DbFilePath = Path.Combine(appPaths.DataPath, "activitylog.db");
|
DbFilePath = Path.Combine(appPaths.DataPath, "activitylog.db");
|
||||||
|
FileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InitializeInternal();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error loading database file. Will reset and retry.", ex);
|
||||||
|
|
||||||
|
FileSystem.DeleteFile(DbFilePath);
|
||||||
|
|
||||||
|
InitializeInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeInternal()
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
@ -879,7 +879,7 @@ namespace Emby.Server.Implementations
|
|||||||
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
|
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
|
||||||
RegisterSingleInstance(UserRepository);
|
RegisterSingleInstance(UserRepository);
|
||||||
|
|
||||||
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager.GetLogger("SqliteDisplayPreferencesRepository"), JsonSerializer, ApplicationPaths, MemoryStreamFactory);
|
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager.GetLogger("SqliteDisplayPreferencesRepository"), JsonSerializer, ApplicationPaths, MemoryStreamFactory, FileSystemManager);
|
||||||
DisplayPreferencesRepository = displayPreferencesRepo;
|
DisplayPreferencesRepository = displayPreferencesRepo;
|
||||||
RegisterSingleInstance(DisplayPreferencesRepository);
|
RegisterSingleInstance(DisplayPreferencesRepository);
|
||||||
|
|
||||||
@ -997,7 +997,7 @@ namespace Emby.Server.Implementations
|
|||||||
EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
|
EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
|
||||||
RegisterSingleInstance(EncodingManager);
|
RegisterSingleInstance(EncodingManager);
|
||||||
|
|
||||||
var sharingRepo = new SharingRepository(LogManager.GetLogger("SharingRepository"), ApplicationPaths);
|
var sharingRepo = new SharingRepository(LogManager.GetLogger("SharingRepository"), ApplicationPaths, FileSystemManager);
|
||||||
sharingRepo.Initialize();
|
sharingRepo.Initialize();
|
||||||
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
|
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
|
||||||
RegisterSingleInstance<ISharingRepository>(sharingRepo);
|
RegisterSingleInstance<ISharingRepository>(sharingRepo);
|
||||||
@ -1351,7 +1351,7 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
private IActivityRepository GetActivityLogRepository()
|
private IActivityRepository GetActivityLogRepository()
|
||||||
{
|
{
|
||||||
var repo = new ActivityRepository(LogManager.GetLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths);
|
var repo = new ActivityRepository(LogManager.GetLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths, FileSystemManager);
|
||||||
|
|
||||||
repo.Initialize();
|
repo.Initialize();
|
||||||
|
|
||||||
|
@ -108,6 +108,8 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
|
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (string.IsNullOrWhiteSpace(_defaultWal))
|
if (string.IsNullOrWhiteSpace(_defaultWal))
|
||||||
{
|
{
|
||||||
_defaultWal = db.Query("PRAGMA journal_mode").SelectScalarString().First();
|
_defaultWal = db.Query("PRAGMA journal_mode").SelectScalarString().First();
|
||||||
@ -140,6 +142,16 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
db.Execute(query);
|
db.Execute(query);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
using (db)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
_connection = new ManagedConnection(db, false);
|
_connection = new ManagedConnection(db, false);
|
||||||
|
|
||||||
@ -264,6 +276,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
protected virtual void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
|
{
|
||||||
|
DisposeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisposeConnection()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -275,7 +293,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
using (_connection)
|
using (_connection)
|
||||||
{
|
{
|
||||||
|
_connection.Close();
|
||||||
}
|
}
|
||||||
_connection = null;
|
_connection = null;
|
||||||
}
|
}
|
||||||
@ -289,7 +307,6 @@ namespace Emby.Server.Implementations.Data
|
|||||||
Logger.ErrorException("Error disposing database", ex);
|
Logger.ErrorException("Error disposing database", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void CloseConnection()
|
protected virtual void CloseConnection()
|
||||||
{
|
{
|
||||||
|
@ -19,12 +19,14 @@ namespace Emby.Server.Implementations.Data
|
|||||||
public class SqliteDisplayPreferencesRepository : BaseSqliteRepository, IDisplayPreferencesRepository
|
public class SqliteDisplayPreferencesRepository : BaseSqliteRepository, IDisplayPreferencesRepository
|
||||||
{
|
{
|
||||||
private readonly IMemoryStreamFactory _memoryStreamProvider;
|
private readonly IMemoryStreamFactory _memoryStreamProvider;
|
||||||
|
protected IFileSystem FileSystem { get; private set; }
|
||||||
|
|
||||||
public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IMemoryStreamFactory memoryStreamProvider)
|
public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IMemoryStreamFactory memoryStreamProvider, IFileSystem fileSystem)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_memoryStreamProvider = memoryStreamProvider;
|
_memoryStreamProvider = memoryStreamProvider;
|
||||||
|
FileSystem = fileSystem;
|
||||||
DbFilePath = Path.Combine(appPaths.DataPath, "displaypreferences.db");
|
DbFilePath = Path.Combine(appPaths.DataPath, "displaypreferences.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,11 +47,27 @@ namespace Emby.Server.Implementations.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InitializeInternal();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error loading database file. Will reset and retry.", ex);
|
||||||
|
|
||||||
|
FileSystem.DeleteFile(DbFilePath);
|
||||||
|
|
||||||
|
InitializeInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the connection to the database
|
/// Opens the connection to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public void Initialize()
|
private void InitializeInternal()
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
@ -120,13 +120,13 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
protected override void CloseConnection()
|
protected override void CloseConnection()
|
||||||
{
|
{
|
||||||
base.CloseConnection();
|
|
||||||
|
|
||||||
if (_shrinkMemoryTimer != null)
|
if (_shrinkMemoryTimer != null)
|
||||||
{
|
{
|
||||||
_shrinkMemoryTimer.Dispose();
|
_shrinkMemoryTimer.Dispose();
|
||||||
_shrinkMemoryTimer = null;
|
_shrinkMemoryTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base.CloseConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -38,7 +38,7 @@ namespace Emby.Server.Implementations.Notifications
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.ErrorException("Error loading notifications database file. Will reset and retry.", ex);
|
Logger.ErrorException("Error loading database file. Will reset and retry.", ex);
|
||||||
|
|
||||||
FileSystem.DeleteFile(DbFilePath);
|
FileSystem.DeleteFile(DbFilePath);
|
||||||
|
|
||||||
|
@ -7,22 +7,42 @@ using MediaBrowser.Model.Logging;
|
|||||||
using MediaBrowser.Model.Social;
|
using MediaBrowser.Model.Social;
|
||||||
using SQLitePCL.pretty;
|
using SQLitePCL.pretty;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Social
|
namespace Emby.Server.Implementations.Social
|
||||||
{
|
{
|
||||||
public class SharingRepository : BaseSqliteRepository, ISharingRepository
|
public class SharingRepository : BaseSqliteRepository, ISharingRepository
|
||||||
{
|
{
|
||||||
public SharingRepository(ILogger logger, IApplicationPaths appPaths)
|
protected IFileSystem FileSystem { get; private set; }
|
||||||
|
|
||||||
|
public SharingRepository(ILogger logger, IApplicationPaths appPaths, IFileSystem fileSystem)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
{
|
{
|
||||||
|
FileSystem = fileSystem;
|
||||||
DbFilePath = Path.Combine(appPaths.DataPath, "shares.db");
|
DbFilePath = Path.Combine(appPaths.DataPath, "shares.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InitializeInternal();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error loading database file. Will reset and retry.", ex);
|
||||||
|
|
||||||
|
FileSystem.DeleteFile(DbFilePath);
|
||||||
|
|
||||||
|
InitializeInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the connection to the database
|
/// Opens the connection to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public void Initialize()
|
private void InitializeInternal()
|
||||||
{
|
{
|
||||||
using (var connection = CreateConnection())
|
using (var connection = CreateConnection())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user