Merge pull request #1883 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-06-27 11:38:34 -04:00 committed by GitHub
commit e49112c3db
3 changed files with 59 additions and 8 deletions

View File

@ -52,6 +52,23 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="dtoService">The dto service.</param> /// <param name="dtoService">The dto service.</param>
public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILocalizationManager localization, IDtoService dtoService) 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; _userManager = userManager;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_localization = localization; _localization = localization;
@ -65,6 +82,11 @@ namespace MediaBrowser.Api.UserLibrary
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public async Task<object> Get(GetItems request) public async Task<object> Get(GetItems request)
{ {
if (request == null)
{
throw new ArgumentNullException("request");
}
var result = await GetItems(request).ConfigureAwait(false); var result = await GetItems(request).ConfigureAwait(false);
return ToOptimizedSerializedResultUsingCache(result); return ToOptimizedSerializedResultUsingCache(result);
@ -81,12 +103,29 @@ namespace MediaBrowser.Api.UserLibrary
var result = await GetItemsToSerialize(request, user).ConfigureAwait(false); var result = await GetItemsToSerialize(request, user).ConfigureAwait(false);
if (result == null)
{
throw new InvalidOperationException("GetItemsToSerialize returned null");
}
if (result.Items == null)
{
throw new InvalidOperationException("GetItemsToSerialize result.Items returned null");
}
var dtoOptions = GetDtoOptions(request); 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 return new ItemsResult
{ {
TotalRecordCount = result.TotalRecordCount, TotalRecordCount = result.TotalRecordCount,
Items = (await _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user).ConfigureAwait(false)).ToArray() Items = dtoList.ToArray()
}; };
} }

View File

@ -161,6 +161,8 @@ namespace MediaBrowser.Providers.Manager
{ {
var currentPath = currentImage.Path; var currentPath = currentImage.Path;
_logger.Debug("Deleting previous image {0}", currentPath);
_libraryMonitor.ReportFileSystemChangeBeginning(currentPath); _libraryMonitor.ReportFileSystemChangeBeginning(currentPath);
try try
@ -276,7 +278,7 @@ namespace MediaBrowser.Providers.Manager
/// <returns>IEnumerable{System.String}.</returns> /// <returns>IEnumerable{System.String}.</returns>
private string[] GetSavePaths(IHasImages item, ImageType type, int? imageIndex, string mimeType, bool saveLocally) 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) }; return new[] { GetStandardSavePath(item, type, imageIndex, mimeType, saveLocally) };
} }

View File

@ -88,6 +88,16 @@ namespace MediaBrowser.Server.Implementations.Dto
public async Task<List<BaseItemDto>> GetBaseItemDtos(IEnumerable<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null) public async Task<List<BaseItemDto>> GetBaseItemDtos(IEnumerable<BaseItem> 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 syncJobItems = GetSyncedItemProgress(options);
var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems); var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems);