reduce chapter db calls

This commit is contained in:
Luke Pulverenti 2013-06-18 15:43:14 -04:00
parent 5d8ed2c16f
commit 35af13fdc7
3 changed files with 8 additions and 6 deletions

View File

@ -679,7 +679,7 @@ namespace MediaBrowser.Api.Images
}
// See if we can avoid a file system lookup by looking for the file in ResolveArgs
var originalFileImageDateModified = kernel.ImageManager.GetImageDateModified(item, request.Type, index);
var originalFileImageDateModified = kernel.ImageManager.GetImageDateModified(item, imagePath);
var supportedImageEnhancers = request.EnableImageEnhancers ? kernel.ImageManager.ImageEnhancers.Where(i =>
{
@ -723,7 +723,8 @@ namespace MediaBrowser.Api.Images
Item = currentItem,
Request = currentRequest,
OriginalImageDateModified = originalFileImageDateModified,
Enhancers = supportedImageEnhancers
Enhancers = supportedImageEnhancers,
OriginalImagePath = imagePath
}, contentType);
}

View File

@ -33,6 +33,8 @@ namespace MediaBrowser.Api.Images
/// </summary>
public DateTime OriginalImageDateModified;
public string OriginalImagePath;
/// <summary>
/// The _options
/// </summary>
@ -71,7 +73,7 @@ namespace MediaBrowser.Api.Images
cropwhitespace = Request.CropWhitespace.Value;
}
return Kernel.Instance.ImageManager.ProcessImage(Item, Request.Type, Request.Index ?? 0, cropwhitespace,
return Kernel.Instance.ImageManager.ProcessImage(Item, Request.Type, Request.Index ?? 0, OriginalImagePath, cropwhitespace,
OriginalImageDateModified, responseStream, Request.Width, Request.Height, Request.MaxWidth,
Request.MaxHeight, Request.Quality, Enhancers);
}

View File

@ -96,6 +96,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="entity">The entity that owns the image</param>
/// <param name="imageType">The image type</param>
/// <param name="imageIndex">The image index (currently only used with backdrops)</param>
/// <param name="originalImagePath">The original image path.</param>
/// <param name="cropWhitespace">if set to <c>true</c> [crop whitespace].</param>
/// <param name="dateModified">The last date modified of the original image file</param>
/// <param name="toStream">The stream to save the new image to</param>
@ -107,7 +108,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="enhancers">The enhancers.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">entity</exception>
public async Task ProcessImage(BaseItem entity, ImageType imageType, int imageIndex, bool cropWhitespace, DateTime dateModified, Stream toStream, int? width, int? height, int? maxWidth, int? maxHeight, int? quality, List<IImageEnhancer> enhancers)
public async Task ProcessImage(BaseItem entity, ImageType imageType, int imageIndex, string originalImagePath, bool cropWhitespace, DateTime dateModified, Stream toStream, int? width, int? height, int? maxWidth, int? maxHeight, int? quality, List<IImageEnhancer> enhancers)
{
if (entity == null)
{
@ -119,8 +120,6 @@ namespace MediaBrowser.Controller.Drawing
throw new ArgumentNullException("toStream");
}
var originalImagePath = GetImagePath(entity, imageType, imageIndex);
if (cropWhitespace)
{
originalImagePath = await GetCroppedImage(originalImagePath, dateModified).ConfigureAwait(false);