Fix possible nullref

This commit is contained in:
Bond_009 2019-08-14 20:24:44 +02:00
parent f8202384a6
commit e5b163b86a

View file

@ -121,6 +121,8 @@ namespace Emby.Server.Implementations
/// </summary> /// </summary>
public abstract class ApplicationHost : IServerApplicationHost, IDisposable public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{ {
private SqliteUserRepository _userRepository;
/// <summary> /// <summary>
/// Gets a value indicating whether this instance can self restart. /// Gets a value indicating whether this instance can self restart.
/// </summary> /// </summary>
@ -291,8 +293,6 @@ namespace Emby.Server.Implementations
/// <value>The user data repository.</value> /// <value>The user data repository.</value>
private IUserDataManager UserDataManager { get; set; } private IUserDataManager UserDataManager { get; set; }
private IUserRepository UserRepository { get; set; }
internal SqliteItemRepository ItemRepository { get; set; } internal SqliteItemRepository ItemRepository { get; set; }
private INotificationManager NotificationManager { get; set; } private INotificationManager NotificationManager { get; set; }
@ -766,9 +766,9 @@ namespace Emby.Server.Implementations
AuthenticationRepository = GetAuthenticationRepository(); AuthenticationRepository = GetAuthenticationRepository();
serviceCollection.AddSingleton(AuthenticationRepository); 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); serviceCollection.AddSingleton(UserManager);
LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager); LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
@ -961,8 +961,8 @@ namespace Emby.Server.Implementations
/// <summary> /// <summary>
/// Gets the user repository. /// Gets the user repository.
/// </summary> /// </summary>
/// <returns>Task{IUserRepository}.</returns> /// <returns><see cref="Task{SqliteUserRepository}" />.</returns>
private IUserRepository GetUserRepository() private SqliteUserRepository GetUserRepository()
{ {
var repo = new SqliteUserRepository(LoggerFactory, ApplicationPaths, JsonSerializer); var repo = new SqliteUserRepository(LoggerFactory, ApplicationPaths, JsonSerializer);
@ -1910,11 +1910,9 @@ namespace Emby.Server.Implementations
} }
} }
UserRepository.Dispose(); _userRepository?.Dispose();
} }
UserRepository = null;
_disposed = true; _disposed = true;
} }
} }