diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs index 438766c0f..475c0b3c4 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs @@ -88,5 +88,17 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo info.Width.Should().Be(480); } + + [Test] + public void should_dispose_file_after_scanning_mediainfo() + { + var path = Path.Combine(Directory.GetCurrentDirectory(), "Files", "Media", "H264_sample.mp4"); + + var info = Subject.GetMediaInfo(path); + + var stream = new FileStream(path, FileMode.Open, FileAccess.Write); + + stream.Close(); + } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs index e43b3cf48..61a1d84ef 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs @@ -41,7 +41,12 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo mediaInfo.Option("ParseSpeed", "0.2"); - int open = mediaInfo.Open(_diskProvider.OpenReadStream(filename)); + int open; + + using (var stream = _diskProvider.OpenReadStream(filename)) + { + open = mediaInfo.Open(stream); + } if (open != 0) {