better error handling with image enhancers
This commit is contained in:
parent
9274f9f35f
commit
ff61b0b11a
|
@ -658,7 +658,20 @@ 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 supportedImageEnhancers = kernel.ImageEnhancers.Where(i => i.Supports(item, request.Type)).ToList();
|
||||
var supportedImageEnhancers = kernel.ImageEnhancers.Where(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return i.Supports(item, request.Type);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}).ToList();
|
||||
|
||||
// If the file does not exist GetLastWriteTimeUtc will return jan 1, 1601 as opposed to throwing an exception
|
||||
// http://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetimeutc.aspx
|
||||
|
|
|
@ -531,8 +531,21 @@ namespace MediaBrowser.Controller.Drawing
|
|||
throw new ArgumentNullException("item");
|
||||
}
|
||||
|
||||
var supportedEnhancers = _kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)).ToList();
|
||||
var supportedEnhancers = _kernel.ImageEnhancers.Where(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return i.Supports(item, imageType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}).ToList();
|
||||
|
||||
// No enhancement - don't cache
|
||||
if (supportedEnhancers.Count == 0)
|
||||
{
|
||||
|
@ -609,7 +622,20 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
var dateModified = GetImageDateModified(item, imagePath);
|
||||
|
||||
var supportedEnhancers = _kernel.ImageEnhancers.Where(i => i.Supports(item, imageType));
|
||||
var supportedEnhancers = _kernel.ImageEnhancers.Where(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return i.Supports(item, imageType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}).ToList();
|
||||
|
||||
return GetImageCacheTag(imagePath, dateModified, supportedEnhancers, item, imageType);
|
||||
}
|
||||
|
|
|
@ -182,11 +182,32 @@ namespace MediaBrowser.Controller.Dto
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (var enhancer in Kernel.Instance.ImageEnhancers
|
||||
.Where(i => i.Supports(item, ImageType.Primary)))
|
||||
var supportedEnhancers = Kernel.Instance.ImageEnhancers.Where(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return i.Supports(item, ImageType.Primary);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);
|
||||
|
||||
size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size);
|
||||
return false;
|
||||
}
|
||||
|
||||
}).ToList();
|
||||
|
||||
|
||||
foreach (var enhancer in supportedEnhancers)
|
||||
{
|
||||
try
|
||||
{
|
||||
size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error in image enhancer: {0}", ex, enhancer.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
dto.PrimaryImageAspectRatio = size.Width / size.Height;
|
||||
|
|
Loading…
Reference in New Issue
Block a user