Skip to content

Commit

Permalink
Merge pull request #3228 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LukePulverenti authored Apr 7, 2018
2 parents 832807b + 6959a01 commit 1786ada
Show file tree
Hide file tree
Showing 133 changed files with 798 additions and 1,240 deletions.
25 changes: 12 additions & 13 deletions Emby.Server.Implementations/ApplicationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,6 @@ protected void RegisterResources()
LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, SystemEvents, EnvironmentInfo);
RegisterSingleInstance(LibraryMonitor);

ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamFactory);
RegisterSingleInstance(ProviderManager);

RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));

CertificateInfo = GetCertificateInfo(true);
Expand All @@ -963,9 +960,6 @@ protected void RegisterResources()
SyncManager = CreateSyncManager();
RegisterSingleInstance(SyncManager);

DtoService = new DtoService(LogManager.GetLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager);
RegisterSingleInstance(DtoService);

var encryptionManager = new EncryptionManager();
RegisterSingleInstance<IEncryptionManager>(encryptionManager);

Expand All @@ -981,12 +975,21 @@ protected void RegisterResources()
var newsService = new Emby.Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
RegisterSingleInstance<INewsService>(newsService);

ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LogManager.GetLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager);
RegisterSingleInstance(ChannelManager);

MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);
RegisterSingleInstance(MediaSourceManager);

SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager);
RegisterSingleInstance(SubtitleManager);

ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamFactory);
RegisterSingleInstance(ProviderManager);

DtoService = new DtoService(LogManager.GetLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager);
RegisterSingleInstance(DtoService);

ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LogManager.GetLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager);
RegisterSingleInstance(ChannelManager);

SessionManager = new SessionManager(UserDataManager, LogManager.GetLogger("SessionManager"), LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager, TimerFactory);
RegisterSingleInstance(SessionManager);

Expand Down Expand Up @@ -1017,9 +1020,6 @@ protected void RegisterResources()
NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);
RegisterSingleInstance(NotificationManager);

SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, MediaSourceManager, ServerConfigurationManager, LocalizationManager);
RegisterSingleInstance(SubtitleManager);

RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LogManager.GetLogger("IDeviceDiscovery"), ServerConfigurationManager, SocketFactory, TimerFactory));

ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
Expand Down Expand Up @@ -1403,7 +1403,6 @@ protected void FindParts()
StartServer();

LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
GetExports<IVirtualFolderCreator>(),
GetExports<IItemResolver>(),
GetExports<IIntroProvider>(),
GetExports<IBaseItemComparer>(),
Expand Down
10 changes: 6 additions & 4 deletions Emby.Server.Implementations/Channels/ChannelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private async Task<Channel> GetChannel(IChannel channelInfo, CancellationToken c
if (isNew)
{
item.OnMetadataChanged();
_libraryManager.CreateItem(item);
_libraryManager.CreateItem(item, null);
}

await item.RefreshMetadata(new MetadataRefreshOptions(_fileSystem)
Expand Down Expand Up @@ -720,7 +720,7 @@ public async Task<QueryResult<BaseItem>> GetChannelItemsInternal(InternalItemsQu
if (itemsResult != null)
{
var internalItems = itemsResult.Items
.Select(i => GetChannelItemEntity(i, channelProvider, channel.Id, parentItem.Id, cancellationToken))
.Select(i => GetChannelItemEntity(i, channelProvider, channel.Id, parentItem, cancellationToken))
.ToArray();

var existingIds = _libraryManager.GetItemIds(query);
Expand Down Expand Up @@ -934,8 +934,10 @@ private T GetItemById<T>(string idString, string channelName, out bool isNew)
return item;
}

private BaseItem GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Guid internalChannelId, Guid parentFolderId, CancellationToken cancellationToken)
private BaseItem GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Guid internalChannelId, BaseItem parentFolder, CancellationToken cancellationToken)
{
var parentFolderId = parentFolder.Id;

BaseItem item;
bool isNew;
bool forceUpdate = false;
Expand Down Expand Up @@ -1156,7 +1158,7 @@ private BaseItem GetChannelItemEntity(ChannelItemInfo info, IChannel channelProv

if (isNew)
{
_libraryManager.CreateItem(item);
_libraryManager.CreateItem(item, parentFolder);

if (info.People != null && info.People.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected override List<BaseItem> GetItemsWithImages(BaseItem item)
return subItem;
}
var parent = subItem.IsOwnedItem ? subItem.GetOwner() : subItem.GetParent();
var parent = subItem.GetOwner() ?? subItem.GetParent();
if (parent != null && parent.HasImage(ImageType.Primary))
{
Expand Down
20 changes: 10 additions & 10 deletions Emby.Server.Implementations/Data/SqliteItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ private void SaveItem(BaseItem item, BaseItem topParent, string userDataKey, ISt
saveItemStatement.TryBind("@ProductionYear", item.ProductionYear);

var parentId = item.ParentId;
if (parentId == Guid.Empty)
if (parentId.Equals(Guid.Empty))
{
saveItemStatement.TryBindNull("@ParentId");
}
Expand Down Expand Up @@ -1251,7 +1251,7 @@ public ItemImageInfo ItemImageInfoFromValueString(string value)
/// <exception cref="System.ArgumentException"></exception>
public BaseItem RetrieveItem(Guid id)
{
if (id == Guid.Empty)
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
}
Expand Down Expand Up @@ -2044,7 +2044,7 @@ public void SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews
public List<ChapterInfo> GetChapters(Guid id)
{
CheckDisposed();
if (id == Guid.Empty)
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
}
Expand Down Expand Up @@ -2080,7 +2080,7 @@ public List<ChapterInfo> GetChapters(Guid id)
public ChapterInfo GetChapter(Guid id, int index)
{
CheckDisposed();
if (id == Guid.Empty)
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
}
Expand Down Expand Up @@ -2141,7 +2141,7 @@ public void SaveChapters(Guid id, List<ChapterInfo> chapters)
{
CheckDisposed();

if (id == Guid.Empty)
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
}
Expand Down Expand Up @@ -4821,7 +4821,7 @@ private IEnumerable<string> MapIncludeItemTypes(string value)

public void DeleteItem(Guid id, CancellationToken cancellationToken)
{
if (id == Guid.Empty)
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
}
Expand Down Expand Up @@ -5022,7 +5022,7 @@ private List<string> GetPeopleWhereClauses(InternalPeopleQuery query, IStatement

private void UpdateAncestors(Guid itemId, List<Guid> ancestorIds, IDatabaseConnection db, IStatement deleteAncestorsStatement, IStatement updateAncestorsStatement)
{
if (itemId == Guid.Empty)
if (itemId.Equals(Guid.Empty))
{
throw new ArgumentNullException("itemId");
}
Expand Down Expand Up @@ -5508,7 +5508,7 @@ private List<Tuple<int, string>> GetItemValuesToSave(BaseItem item, List<string>

private void UpdateItemValues(Guid itemId, List<Tuple<int, string>> values, IDatabaseConnection db)
{
if (itemId == Guid.Empty)
if (itemId.Equals(Guid.Empty))
{
throw new ArgumentNullException("itemId");
}
Expand Down Expand Up @@ -5559,7 +5559,7 @@ private void UpdateItemValues(Guid itemId, List<Tuple<int, string>> values, IDat

public void UpdatePeople(Guid itemId, List<PersonInfo> people)
{
if (itemId == Guid.Empty)
if (itemId.Equals(Guid.Empty))
{
throw new ArgumentNullException("itemId");
}
Expand Down Expand Up @@ -5691,7 +5691,7 @@ public void SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationTok
{
CheckDisposed();

if (id == Guid.Empty)
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
}
Expand Down
10 changes: 5 additions & 5 deletions Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void SaveUserData(Guid userId, string key, UserItemData userData, Cancell
{
throw new ArgumentNullException("userData");
}
if (userId == Guid.Empty)
if (userId.Equals(Guid.Empty))
{
throw new ArgumentNullException("userId");
}
Expand All @@ -128,7 +128,7 @@ public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationTo
{
throw new ArgumentNullException("userData");
}
if (userId == Guid.Empty)
if (userId.Equals(Guid.Empty))
{
throw new ArgumentNullException("userId");
}
Expand Down Expand Up @@ -247,7 +247,7 @@ private void PersistAllUserData(Guid userId, UserItemData[] userDataList, Cancel
/// </exception>
public UserItemData GetUserData(Guid userId, string key)
{
if (userId == Guid.Empty)
if (userId.Equals(Guid.Empty))
{
throw new ArgumentNullException("userId");
}
Expand Down Expand Up @@ -278,7 +278,7 @@ public UserItemData GetUserData(Guid userId, string key)

public UserItemData GetUserData(Guid userId, List<string> keys)
{
if (userId == Guid.Empty)
if (userId.Equals(Guid.Empty))
{
throw new ArgumentNullException("userId");
}
Expand All @@ -302,7 +302,7 @@ public UserItemData GetUserData(Guid userId, List<string> keys)
/// <returns></returns>
public List<UserItemData> GetAllUserData(Guid userId)
{
if (userId == Guid.Empty)
if (userId.Equals(Guid.Empty))
{
throw new ArgumentNullException("userId");
}
Expand Down
9 changes: 1 addition & 8 deletions Emby.Server.Implementations/Dto/DtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,13 +1325,6 @@ private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem owner, D
dto.IndexNumberEnd = episode.IndexNumberEnd;
dto.SeriesName = episode.SeriesName;

if (fields.Contains(ItemFields.AlternateEpisodeNumbers))
{
dto.DvdSeasonNumber = episode.DvdSeasonNumber;
dto.DvdEpisodeNumber = episode.DvdEpisodeNumber;
dto.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
}

if (fields.Contains(ItemFields.SpecialEpisodeNumbers))
{
dto.AirsAfterSeasonNumber = episode.AirsAfterSeasonNumber;
Expand Down Expand Up @@ -1480,7 +1473,7 @@ private BaseItem GetImageDisplayParent(BaseItem currentItem, BaseItem originalIt
}
}

var parent = currentItem.DisplayParent ?? (currentItem.IsOwnedItem ? currentItem.GetOwner() : currentItem.GetParent());
var parent = currentItem.DisplayParent ?? currentItem.GetOwner() ?? currentItem.GetParent();

if (parent == null && !(originalItem is UserRootFolder) && !(originalItem is UserView) && !(originalItem is AggregateFolder) && !(originalItem is ICollectionFolder) && !(originalItem is Channel))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@
<Compile Include="Playlists\ManualPlaylistsFolder.cs" />
<Compile Include="Playlists\PlaylistImageProvider.cs" />
<Compile Include="Playlists\PlaylistManager.cs" />
<Compile Include="Playlists\PlaylistsDynamicFolder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reflection\AssemblyInfo.cs" />
<Compile Include="ResourceFileManager.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void _userDataManager_UserDataSaved(object sender, UserDataSaveEventArgs e)
// Go up one level for indicators
if (baseItem != null)
{
var parent = baseItem.IsOwnedItem ? baseItem.GetOwner() : baseItem.GetParent();
var parent = baseItem.GetOwner() ?? baseItem.GetParent();

if (parent != null)
{
Expand Down
6 changes: 3 additions & 3 deletions Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ private string SerializeToXmlString(object from)
public object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)
where T : class
{
if (cacheKey == Guid.Empty)
if (cacheKey.Equals(Guid.Empty))
{
throw new ArgumentNullException("cacheKey");
}
Expand Down Expand Up @@ -394,7 +394,7 @@ public object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cach
public object GetCachedResult<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)
where T : class
{
if (cacheKey == Guid.Empty)
if (cacheKey.Equals(Guid.Empty))
{
throw new ArgumentNullException("cacheKey");
}
Expand Down Expand Up @@ -551,7 +551,7 @@ public async Task<object> GetStaticResult(IRequest requestContext, StaticResultO
options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var contentType = options.ContentType;

if (cacheKey == Guid.Empty)
if (cacheKey.Equals(Guid.Empty))
{
throw new ArgumentNullException("cacheKey");
}
Expand Down
3 changes: 1 addition & 2 deletions Emby.Server.Implementations/IO/FileRefresher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private BaseItem GetAffectedBaseItem(string path)
// If the item has been deleted find the first valid parent that still exists
while (!_fileSystem.DirectoryExists(item.Path) && !_fileSystem.FileExists(item.Path))
{
item = item.IsOwnedItem ? item.GetOwner() : item.GetParent();
item = item.GetOwner() ?? item.GetParent();

if (item == null)
{
Expand Down Expand Up @@ -231,7 +231,6 @@ public void Dispose()
{
_disposed = true;
DisposeTimer();
GC.SuppressFinalize(this);
}
}
}
1 change: 0 additions & 1 deletion Emby.Server.Implementations/IO/IsoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void Dispose()
{
mounter.Dispose();
}
GC.SuppressFinalize(this);
}
}
}
2 changes: 0 additions & 2 deletions Emby.Server.Implementations/IO/LibraryMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ public void Dispose()
{
_disposed = true;
Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
Expand Down Expand Up @@ -654,7 +653,6 @@ public void Run()

public void Dispose()
{
GC.SuppressFinalize(this);
}
}
}
Loading

0 comments on commit 1786ada

Please sign in to comment.