mirror of
https://github.com/Sonarr/Sonarr
synced 2025-03-11 06:33:32 +00:00
Fixed: Don't set last write time on episode files if difference is within the same second
Closes #7228
This commit is contained in:
parent
75fae9262c
commit
c199fd05d3
2 changed files with 11 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Common.Extensions
|
||||
{
|
||||
|
@ -38,5 +38,10 @@ namespace NzbDrone.Common.Extensions
|
|||
{
|
||||
return dateTime >= afterDateTime && dateTime <= beforeDateTime;
|
||||
}
|
||||
|
||||
public static DateTime WithoutTicks(this DateTime dateTime)
|
||||
{
|
||||
return dateTime.AddTicks(-(dateTime.Ticks % TimeSpan.TicksPerSecond));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
if (DateTime.TryParse(fileDate + ' ' + fileTime, out var airDate))
|
||||
{
|
||||
// avoiding false +ve checks and set date skewing by not using UTC (Windows)
|
||||
var oldDateTime = _diskProvider.FileGetLastWrite(filePath);
|
||||
var oldLastWrite = _diskProvider.FileGetLastWrite(filePath);
|
||||
|
||||
if (OsInfo.IsNotWindows && airDate < EpochTime)
|
||||
{
|
||||
|
@ -92,12 +92,12 @@ namespace NzbDrone.Core.MediaFiles
|
|||
airDate = EpochTime;
|
||||
}
|
||||
|
||||
if (!DateTime.Equals(airDate, oldDateTime))
|
||||
if (!DateTime.Equals(airDate.WithoutTicks(), oldLastWrite.WithoutTicks()))
|
||||
{
|
||||
try
|
||||
{
|
||||
_diskProvider.FileSetLastWriteTime(filePath, airDate);
|
||||
_logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldDateTime, airDate);
|
||||
_logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldLastWrite, airDate);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -125,11 +125,11 @@ namespace NzbDrone.Core.MediaFiles
|
|||
airDateUtc = EpochTime;
|
||||
}
|
||||
|
||||
if (!DateTime.Equals(airDateUtc, oldLastWrite))
|
||||
if (!DateTime.Equals(airDateUtc.WithoutTicks(), oldLastWrite.WithoutTicks()))
|
||||
{
|
||||
try
|
||||
{
|
||||
_diskProvider.FileSetLastWriteTime(filePath, airDateUtc);
|
||||
_diskProvider.FileSetLastWriteTime(filePath, airDateUtc.AddMilliseconds(oldLastWrite.Millisecond));
|
||||
_logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldLastWrite, airDateUtc);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue