Fixed: Set release date to 1970-01-01 if track released before (mono)

This commit is contained in:
Qstick 2017-12-31 15:09:57 -05:00
parent f814b5a6e1
commit 8ce1d4bcab
1 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
@ -26,6 +27,7 @@ namespace NzbDrone.Core.MediaFiles
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly ITrackService _trackService; private readonly ITrackService _trackService;
private readonly Logger _logger; private readonly Logger _logger;
private static readonly DateTime EpochTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public UpdateTrackFileService(IDiskProvider diskProvider, public UpdateTrackFileService(IDiskProvider diskProvider,
IConfigService configService, IConfigService configService,
@ -66,6 +68,12 @@ namespace NzbDrone.Core.MediaFiles
// avoiding false +ve checks and set date skewing by not using UTC (Windows) // avoiding false +ve checks and set date skewing by not using UTC (Windows)
DateTime oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath); DateTime oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath);
if (OsInfo.IsNotWindows && relDate < EpochTime)
{
_logger.Debug("Setting date of file to 1970-01-01 as actual airdate is before that time and will not be set properly");
relDate = EpochTime;
}
if (!DateTime.Equals(relDate, oldDateTime)) if (!DateTime.Equals(relDate, oldDateTime))
{ {
try try
@ -96,12 +104,12 @@ namespace NzbDrone.Core.MediaFiles
return; return;
} }
var episodes = _trackService.TracksWithFiles(message.Artist.Id); var tracks = _trackService.TracksWithFiles(message.Artist.Id);
var trackFiles = new List<TrackFile>(); var trackFiles = new List<TrackFile>();
var updated = new List<TrackFile>(); var updated = new List<TrackFile>();
foreach (var group in episodes.GroupBy(e => e.TrackFileId)) foreach (var group in tracks.GroupBy(e => e.TrackFileId))
{ {
var tracksInFile = group.Select(e => e).ToList(); var tracksInFile = group.Select(e => e).ToList();
var trackFile = tracksInFile.First().TrackFile; var trackFile = tracksInFile.First().TrackFile;