diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 09847b2f8..966abfc41 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -121,6 +121,10 @@ namespace Emby.Server.Implementations
///
public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{
+ private SqliteUserRepository _userRepository;
+
+ private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
+
///
/// Gets a value indicating whether this instance can self restart.
///
@@ -291,8 +295,6 @@ namespace Emby.Server.Implementations
/// The user data repository.
private IUserDataManager UserDataManager { get; set; }
- private IUserRepository UserRepository { get; set; }
-
internal SqliteItemRepository ItemRepository { get; set; }
private INotificationManager NotificationManager { get; set; }
@@ -757,8 +759,12 @@ namespace Emby.Server.Implementations
UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, () => UserManager);
serviceCollection.AddSingleton(UserDataManager);
- var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager);
- serviceCollection.AddSingleton(displayPreferencesRepo);
+ _displayPreferencesRepository = new SqliteDisplayPreferencesRepository(
+ LoggerFactory.CreateLogger(),
+ JsonSerializer,
+ ApplicationPaths,
+ FileSystemManager);
+ serviceCollection.AddSingleton(_displayPreferencesRepository);
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, LocalizationManager);
serviceCollection.AddSingleton(ItemRepository);
@@ -766,9 +772,9 @@ namespace Emby.Server.Implementations
AuthenticationRepository = GetAuthenticationRepository();
serviceCollection.AddSingleton(AuthenticationRepository);
- UserRepository = GetUserRepository();
+ _userRepository = GetUserRepository();
- UserManager = new UserManager(LoggerFactory, ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager);
+ UserManager = new UserManager(LoggerFactory, ServerConfigurationManager, _userRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager);
serviceCollection.AddSingleton(UserManager);
LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
@@ -884,7 +890,7 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(typeof(IResourceFileManager), typeof(ResourceFileManager));
- displayPreferencesRepo.Initialize();
+ _displayPreferencesRepository.Initialize();
var userDataRepo = new SqliteUserDataRepository(LoggerFactory, ApplicationPaths);
@@ -961,10 +967,13 @@ namespace Emby.Server.Implementations
///
/// Gets the user repository.
///
- /// Task{IUserRepository}.
- private IUserRepository GetUserRepository()
+ /// .
+ private SqliteUserRepository GetUserRepository()
{
- var repo = new SqliteUserRepository(LoggerFactory, ApplicationPaths, JsonSerializer);
+ var repo = new SqliteUserRepository(
+ LoggerFactory.CreateLogger(),
+ ApplicationPaths,
+ JsonSerializer);
repo.Initialize();
@@ -1910,10 +1919,12 @@ namespace Emby.Server.Implementations
}
}
- UserRepository.Dispose();
+ _userRepository?.Dispose();
+ _displayPreferencesRepository.Dispose();
}
- UserRepository = null;
+ _userRepository = null;
+ _displayPreferencesRepository = null;
_disposed = true;
}
diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
index 87096e72f..77f5d9479 100644
--- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
@@ -21,8 +21,8 @@ namespace Emby.Server.Implementations.Data
{
private readonly IFileSystem _fileSystem;
- public SqliteDisplayPreferencesRepository(ILoggerFactory loggerFactory, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem)
- : base(loggerFactory.CreateLogger(nameof(SqliteDisplayPreferencesRepository)))
+ public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem)
+ : base(logger)
{
_jsonSerializer = jsonSerializer;
_fileSystem = fileSystem;
diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
index de2354eef..d6d250fb3 100644
--- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
@@ -18,10 +18,10 @@ namespace Emby.Server.Implementations.Data
private readonly IJsonSerializer _jsonSerializer;
public SqliteUserRepository(
- ILoggerFactory loggerFactory,
+ ILogger logger,
IServerApplicationPaths appPaths,
IJsonSerializer jsonSerializer)
- : base(loggerFactory.CreateLogger(nameof(SqliteUserRepository)))
+ : base(logger)
{
_jsonSerializer = jsonSerializer;