From dc15f930051d209e7bccbd352139a843982a9c62 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 26 Jun 2016 16:35:03 -0400 Subject: [PATCH 1/4] fixes #1787 --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 38 ++++++++++++++++++- .../Dto/DtoService.cs | 10 +++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 7dd5920b7..19cadbec7 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -52,6 +52,23 @@ namespace MediaBrowser.Api.UserLibrary /// The dto service. public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILocalizationManager localization, IDtoService dtoService) { + if (userManager == null) + { + throw new ArgumentNullException("userManager"); + } + if (libraryManager == null) + { + throw new ArgumentNullException("libraryManager"); + } + if (localization == null) + { + throw new ArgumentNullException("localization"); + } + if (dtoService == null) + { + throw new ArgumentNullException("dtoService"); + } + _userManager = userManager; _libraryManager = libraryManager; _localization = localization; @@ -65,6 +82,11 @@ namespace MediaBrowser.Api.UserLibrary /// System.Object. public async Task Get(GetItems request) { + if (request == null) + { + throw new ArgumentNullException("request"); + } + var result = await GetItems(request).ConfigureAwait(false); return ToOptimizedSerializedResultUsingCache(result); @@ -78,15 +100,27 @@ namespace MediaBrowser.Api.UserLibrary private async Task GetItems(GetItems request) { var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; - + var result = await GetItemsToSerialize(request, user).ConfigureAwait(false); + if (result == null) + { + throw new InvalidOperationException("GetItemsToSerialize returned null"); + } + var dtoOptions = GetDtoOptions(request); + var dtoList = await _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user).ConfigureAwait(false); + + if (dtoList == null) + { + throw new InvalidOperationException("GetBaseItemDtos returned null"); + } + return new ItemsResult { TotalRecordCount = result.TotalRecordCount, - Items = (await _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user).ConfigureAwait(false)).ToArray() + Items = dtoList.ToArray() }; } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index f21dd27ff..8805d567a 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -88,6 +88,16 @@ namespace MediaBrowser.Server.Implementations.Dto public async Task> GetBaseItemDtos(IEnumerable items, DtoOptions options, User user = null, BaseItem owner = null) { + if (items == null) + { + throw new ArgumentNullException("items"); + } + + if (options == null) + { + throw new ArgumentNullException("options"); + } + var syncJobItems = GetSyncedItemProgress(options); var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems); From 17e416a0fd681a3ef71e09c58e2af49177afe56e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 26 Jun 2016 16:38:50 -0400 Subject: [PATCH 2/4] add logging --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 19cadbec7..a6f1d8b98 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -108,6 +108,11 @@ namespace MediaBrowser.Api.UserLibrary throw new InvalidOperationException("GetItemsToSerialize returned null"); } + if (result.Items == null) + { + throw new InvalidOperationException("GetItemsToSerialize result.Items returned null"); + } + var dtoOptions = GetDtoOptions(request); var dtoList = await _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user).ConfigureAwait(false); From 7e91d2d4bcb640daa941543f1394cfa270d69ae3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 27 Jun 2016 00:19:10 -0400 Subject: [PATCH 3/4] update list styles --- MediaBrowser.Providers/Manager/ImageSaver.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index bd1961143..eca3c327c 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -161,6 +161,8 @@ namespace MediaBrowser.Providers.Manager { var currentPath = currentImage.Path; + _logger.Debug("Deleting previous image {0}", currentPath); + _libraryMonitor.ReportFileSystemChangeBeginning(currentPath); try @@ -375,11 +377,11 @@ namespace MediaBrowser.Providers.Manager } string filename; - var folderName = item is MusicAlbum || - item is MusicArtist || - item is PhotoAlbum || - (saveLocally && _config.Configuration.ImageSavingConvention == ImageSavingConvention.Legacy) ? - "folder" : + var folderName = item is MusicAlbum || + item is MusicArtist || + item is PhotoAlbum || + (saveLocally && _config.Configuration.ImageSavingConvention == ImageSavingConvention.Legacy) ? + "folder" : "poster"; switch (type) From a6cbba1fd0727cece24f087a573813dfd241ea44 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 27 Jun 2016 11:34:33 -0400 Subject: [PATCH 4/4] update listviews --- MediaBrowser.Providers/Manager/ImageSaver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index eca3c327c..327c14207 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -278,7 +278,7 @@ namespace MediaBrowser.Providers.Manager /// IEnumerable{System.String}. private string[] GetSavePaths(IHasImages item, ImageType type, int? imageIndex, string mimeType, bool saveLocally) { - if (_config.Configuration.ImageSavingConvention == ImageSavingConvention.Legacy || !saveLocally) + if (!saveLocally) { return new[] { GetStandardSavePath(item, type, imageIndex, mimeType, saveLocally) }; }