1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Added additional gdiplus check.

This commit is contained in:
Taloth Saldono 2016-11-05 22:17:08 +01:00
parent 3c8b263694
commit b093be3f4e
3 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Core.MediaCover
{
public static class GdiPlusInterop
{
private static Exception _gdiPlusException;
static GdiPlusInterop()
{
TestLibrary();
}
private static void TestLibrary()
{
if (OsInfo.IsWindows)
{
return;
}
try
{
// We use StringFormat as test coz it gets properly cleaned up by the finalizer even if gdiplus is absent and is relatively non-invasive.
var strFormat = new StringFormat();
strFormat.Dispose();
}
catch (Exception ex)
{
_gdiPlusException = ex;
}
}
public static void CheckGdiPlus()
{
if (_gdiPlusException != null)
{
throw new DllNotFoundException("Couldn't load GDIPlus library", _gdiPlusException);
}
}
}
}

View File

@ -24,6 +24,8 @@ public void Resize(string source, string destination, int height)
{ {
try try
{ {
GdiPlusInterop.CheckGdiPlus();
using (var sourceStream = _diskProvider.OpenReadStream(source)) using (var sourceStream = _diskProvider.OpenReadStream(source))
{ {
using (var outputStream = _diskProvider.OpenWriteStream(destination)) using (var outputStream = _diskProvider.OpenWriteStream(destination))

View File

@ -686,6 +686,7 @@
<Compile Include="Lifecycle\Commands\ShutdownCommand.cs" /> <Compile Include="Lifecycle\Commands\ShutdownCommand.cs" />
<Compile Include="Lifecycle\LifecycleService.cs" /> <Compile Include="Lifecycle\LifecycleService.cs" />
<Compile Include="MediaCover\CoverAlreadyExistsSpecification.cs" /> <Compile Include="MediaCover\CoverAlreadyExistsSpecification.cs" />
<Compile Include="MediaCover\GdiPlusInterop.cs" />
<Compile Include="MediaCover\MediaCover.cs" /> <Compile Include="MediaCover\MediaCover.cs" />
<Compile Include="MediaCover\ImageResizer.cs" /> <Compile Include="MediaCover\ImageResizer.cs" />
<Compile Include="MediaCover\MediaCoverService.cs" /> <Compile Include="MediaCover\MediaCoverService.cs" />