1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-31 03:11:07 +02:00

Fixed not setting MediaInfo SchemaRevision first time causing it to be fetched again during the series rescan.

This commit is contained in:
Taloth Saldono 2017-08-14 20:02:15 +02:00
parent f53cad822a
commit 34ded19be4
3 changed files with 7 additions and 8 deletions

View File

@ -60,7 +60,7 @@ public void should_skip_up_to_date_media_info()
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = UpdateMediaInfoService.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()
@ -86,7 +86,7 @@ public void should_skip_not_yet_date_media_info()
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = UpdateMediaInfoService.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()

View File

@ -18,9 +18,6 @@ public class UpdateMediaInfoService : IHandle<SeriesScannedEvent>
private readonly IConfigService _configService;
private readonly Logger _logger;
public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 3;
public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 4;
public UpdateMediaInfoService(IDiskProvider diskProvider,
IMediaFileService mediaFileService,
IVideoFileInfoReader videoFileInfoReader,
@ -50,7 +47,6 @@ private void UpdateMediaInfo(Series series, List<EpisodeFile> mediaFiles)
if (mediaFile.MediaInfo != null)
{
mediaFile.MediaInfo.SchemaRevision = CURRENT_MEDIA_INFO_SCHEMA_REVISION;
_mediaFileService.Update(mediaFile);
_logger.Debug("Updated MediaInfo for '{0}'", path);
}
@ -66,7 +62,7 @@ public void Handle(SeriesScannedEvent message)
}
var allMediaFiles = _mediaFileService.GetFilesBySeries(message.Series.Id);
var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < MINIMUM_MEDIA_INFO_SCHEMA_REVISION).ToList();
var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION).ToList();
UpdateMediaInfo(message.Series, filteredMediaFiles);
}

View File

@ -17,6 +17,8 @@ public class VideoFileInfoReader : IVideoFileInfoReader
private readonly IDiskProvider _diskProvider;
private readonly Logger _logger;
public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 3;
public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 4;
public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger)
{
@ -145,7 +147,8 @@ public MediaInfoModel GetMediaInfo(string filename)
VideoFps = videoFrameRate,
AudioLanguages = audioLanguages,
Subtitles = subtitles,
ScanType = scanType
ScanType = scanType,
SchemaRevision = CURRENT_MEDIA_INFO_SCHEMA_REVISION
};
return mediaInfoModel;