reduce chapter db calls

pull/702/head
Luke Pulverenti 11 years ago
parent 5d8ed2c16f
commit 35af13fdc7

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

@ -33,6 +33,8 @@ namespace MediaBrowser.Api.Images
/// </summary> /// </summary>
public DateTime OriginalImageDateModified; public DateTime OriginalImageDateModified;
public string OriginalImagePath;
/// <summary> /// <summary>
/// The _options /// The _options
/// </summary> /// </summary>
@ -71,7 +73,7 @@ namespace MediaBrowser.Api.Images
cropwhitespace = Request.CropWhitespace.Value; 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, OriginalImageDateModified, responseStream, Request.Width, Request.Height, Request.MaxWidth,
Request.MaxHeight, Request.Quality, Enhancers); Request.MaxHeight, Request.Quality, Enhancers);
} }

@ -96,6 +96,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="entity">The entity that owns the image</param> /// <param name="entity">The entity that owns the image</param>
/// <param name="imageType">The image type</param> /// <param name="imageType">The image type</param>
/// <param name="imageIndex">The image index (currently only used with backdrops)</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="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="dateModified">The last date modified of the original image file</param>
/// <param name="toStream">The stream to save the new image to</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> /// <param name="enhancers">The enhancers.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">entity</exception> /// <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) if (entity == null)
{ {
@ -119,8 +120,6 @@ namespace MediaBrowser.Controller.Drawing
throw new ArgumentNullException("toStream"); throw new ArgumentNullException("toStream");
} }
var originalImagePath = GetImagePath(entity, imageType, imageIndex);
if (cropWhitespace) if (cropWhitespace)
{ {
originalImagePath = await GetCroppedImage(originalImagePath, dateModified).ConfigureAwait(false); originalImagePath = await GetCroppedImage(originalImagePath, dateModified).ConfigureAwait(false);

Loading…
Cancel
Save