mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-26 15:52:42 +00:00
Fixed: Set release date to 1970-01-01 if track released before (mono)
This commit is contained in:
parent
f814b5a6e1
commit
8ce1d4bcab
1 changed files with 10 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
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 @@ public class UpdateTrackFileService : IUpdateTrackFileService,
|
|||
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 @@ private bool ChangeFileDate(TrackFile trackFile, Artist artist, List<Track> trac
|
|||
// 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 @@ public void Handle(ArtistScannedEvent message)
|
|||
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…
Reference in a new issue