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