mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
Fixed: No longer leaves a corrupt file if MediaCover resize failed.
This commit is contained in:
@@ -26,6 +26,14 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(v => v.OpenWriteStream(It.IsAny<string>()))
|
||||
.Returns<string>(s => new FileStream(s, FileMode.Create));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(v => v.FileExists(It.IsAny<string>()))
|
||||
.Returns<string>(s => File.Exists(s));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(v => v.DeleteFile(It.IsAny<string>()))
|
||||
.Callback<string>(s => File.Delete(s));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -46,5 +54,18 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
||||
image.Height.Should().Be(170);
|
||||
image.Width.Should().Be(170);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_file_if_failed()
|
||||
{
|
||||
var mainFile = Path.Combine(TempFolder, "junk.png");
|
||||
var resizedFile = Path.Combine(TempFolder, "junk-170.png");
|
||||
|
||||
File.WriteAllText(mainFile, "Just some junk data that should make it throw an Exception.");
|
||||
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Resize(mainFile, resizedFile, 170));
|
||||
|
||||
File.Exists(resizedFile).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user