1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-20 01:42:35 +01:00

Fixed: Importing files without media info available

This commit is contained in:
Bogdan 2024-08-29 14:37:17 +03:00
parent 675612e7c6
commit 4d589422e6
2 changed files with 28 additions and 1 deletions

View File

@ -60,6 +60,7 @@ public void should_skip_up_to_date_media_info()
{ {
var movieFiles = Builder<MovieFile>.CreateListOfSize(3) var movieFiles = Builder<MovieFile>.CreateListOfSize(3)
.All() .All()
.With(v => v.Path = null)
.With(v => v.RelativePath = "media.mkv") .With(v => v.RelativePath = "media.mkv")
.TheFirst(1) .TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.CURRENT_MEDIA_INFO_SCHEMA_REVISION }) .With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
@ -86,6 +87,7 @@ public void should_skip_not_yet_date_media_info()
{ {
var movieFiles = Builder<MovieFile>.CreateListOfSize(3) var movieFiles = Builder<MovieFile>.CreateListOfSize(3)
.All() .All()
.With(v => v.Path = null)
.With(v => v.RelativePath = "media.mkv") .With(v => v.RelativePath = "media.mkv")
.TheFirst(1) .TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION }) .With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
@ -112,6 +114,7 @@ public void should_update_outdated_media_info()
{ {
var movieFiles = Builder<MovieFile>.CreateListOfSize(3) var movieFiles = Builder<MovieFile>.CreateListOfSize(3)
.All() .All()
.With(v => v.Path = null)
.With(v => v.RelativePath = "media.mkv") .With(v => v.RelativePath = "media.mkv")
.TheFirst(1) .TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel()) .With(v => v.MediaInfo = new MediaInfoModel())
@ -161,6 +164,7 @@ public void should_continue_after_failure()
{ {
var movieFiles = Builder<MovieFile>.CreateListOfSize(2) var movieFiles = Builder<MovieFile>.CreateListOfSize(2)
.All() .All()
.With(v => v.Path = null)
.With(v => v.RelativePath = "media.mkv") .With(v => v.RelativePath = "media.mkv")
.TheFirst(1) .TheFirst(1)
.With(v => v.RelativePath = "media2.mkv") .With(v => v.RelativePath = "media2.mkv")
@ -240,6 +244,7 @@ public void should_not_update_if_media_info_disabled()
public void should_update_media_info() public void should_update_media_info()
{ {
var movieFile = Builder<MovieFile>.CreateNew() var movieFile = Builder<MovieFile>.CreateNew()
.With(v => v.Path = null)
.With(v => v.RelativePath = "media.mkv") .With(v => v.RelativePath = "media.mkv")
.With(e => e.MediaInfo = new MediaInfoModel { SchemaRevision = 3 }) .With(e => e.MediaInfo = new MediaInfoModel { SchemaRevision = 3 })
.Build(); .Build();
@ -288,5 +293,26 @@ public void should_not_save_movie_file_if_new_info_is_null()
Mocker.GetMock<IMediaFileService>() Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(movieFile), Times.Never()); .Verify(v => v.Update(movieFile), Times.Never());
} }
[Test]
public void should_not_update_media_info_if_file_does_not_support_media_info()
{
var path = Path.Combine(_movie.Path, "media.iso");
var movieFile = Builder<MovieFile>.CreateNew()
.With(v => v.Path = path)
.Build();
GivenFileExists();
GivenFailedScan(path);
Subject.Update(movieFile, _movie);
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(path), Times.Once());
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(movieFile), Times.Never());
}
} }
} }

View File

@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
@ -68,7 +69,7 @@ public bool Update(MovieFile movieFile, Movie movie)
public bool UpdateMediaInfo(MovieFile movieFile, Movie movie) public bool UpdateMediaInfo(MovieFile movieFile, Movie movie)
{ {
var path = Path.Combine(movie.Path, movieFile.RelativePath); var path = movieFile.Path.IsNotNullOrWhiteSpace() ? movieFile.Path : Path.Combine(movie.Path, movieFile.RelativePath);
if (!_diskProvider.FileExists(path)) if (!_diskProvider.FileExists(path))
{ {