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

pull/181/head
Qstick 7 years ago
parent f814b5a6e1
commit 8ce1d4bcab

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Configuration;
@ -26,6 +27,7 @@ namespace NzbDrone.Core.MediaFiles
private readonly IConfigService _configService;
private readonly ITrackService _trackService;
private readonly Logger _logger;
private static readonly DateTime EpochTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public UpdateTrackFileService(IDiskProvider diskProvider,
IConfigService configService,
@ -66,6 +68,12 @@ namespace NzbDrone.Core.MediaFiles
// avoiding false +ve checks and set date skewing by not using UTC (Windows)
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))
{
try
@ -96,12 +104,12 @@ namespace NzbDrone.Core.MediaFiles
return;
}
var episodes = _trackService.TracksWithFiles(message.Artist.Id);
var tracks = _trackService.TracksWithFiles(message.Artist.Id);
var trackFiles = 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 trackFile = tracksInFile.First().TrackFile;

Loading…
Cancel
Save