Fixed: Memory leak due to unmanaged Bitmaps leaking.

Leonardo Galli 6 years ago
parent 77950645af
commit d38562664d

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.jetbrains.rider.android.RiderAndroidMiscFileCreationComponent">
<option name="ENSURE_MISC_FILE_EXISTS" value="true" />
</component>
</project>

@ -123,27 +123,6 @@ namespace NzbDrone.Common.Disk
} }
} }
public bool IsValidGDIPlusImage(string filename)
{
if (!CanUseGDIPlus())
{
return true;
}
try
{
using (var bmp = new Bitmap(filename))
{
}
return true;
}
catch (Exception ex)
{
Logger.Debug(ex, "Corrupted image found at: {0}.", filename);
return false;
}
}
public bool FolderWritable(string path) public bool FolderWritable(string path)
{ {
Ensure.That(path, () => path).IsValidPath(); Ensure.That(path, () => path).IsValidPath();

@ -20,7 +20,6 @@ namespace NzbDrone.Common.Disk
bool FileExists(string path); bool FileExists(string path);
bool FileExists(string path, StringComparison stringComparison); bool FileExists(string path, StringComparison stringComparison);
bool CanUseGDIPlus(); bool CanUseGDIPlus();
bool IsValidGDIPlusImage(string path);
bool FolderWritable(string path); bool FolderWritable(string path);
string[] GetDirectories(string path); string[] GetDirectories(string path);
string[] GetFiles(string path, SearchOption searchOption); string[] GetFiles(string path, SearchOption searchOption);

@ -37,15 +37,6 @@ namespace NzbDrone.Core.Test.MediaCoverTests
} }
private void GivenImageFileCorrupt(bool corrupt)
{
GivenFileExistsOnDisk();
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.IsValidGDIPlusImage(It.IsAny<string>()))
.Returns(!corrupt);
}
[Test] [Test]
public void should_return_false_if_file_not_exists() public void should_return_false_if_file_not_exists()
{ {
@ -61,21 +52,11 @@ namespace NzbDrone.Core.Test.MediaCoverTests
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse(); Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
} }
[Test]
public void should_return_false_if_file_exists_and_same_size_and_corrupt()
{
GivenExistingFileSize(100);
GivenImageFileCorrupt(true);
_httpResponse.Headers.ContentLength = 100;
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
}
[Test] [Test]
public void should_return_true_if_file_exists_and_same_size_and_not_corrupt() public void should_return_true_if_file_exists_and_same_size_and_not_corrupt()
{ {
GivenExistingFileSize(100); GivenExistingFileSize(100);
GivenImageFileCorrupt(false);
_httpResponse.Headers.ContentLength = 100; _httpResponse.Headers.ContentLength = 100;
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue(); Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue();
} }

@ -31,12 +31,6 @@ namespace NzbDrone.Core.MediaCover
return false; return false;
} }
if (!_diskProvider.IsValidGDIPlusImage(path))
{
_diskProvider.DeleteFile(path);
return false;
}
var headers = _httpClient.Head(new HttpRequest(url)).Headers; var headers = _httpClient.Head(new HttpRequest(url)).Headers;
var fileSize = _diskProvider.GetFileSize(path); var fileSize = _diskProvider.GetFileSize(path);
return fileSize == headers.ContentLength; return fileSize == headers.ContentLength;

@ -74,6 +74,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>

Loading…
Cancel
Save