Fixed: Radarr Changes every file due to timezones (#2533)

Fixes #1741
Qstick 7 years ago committed by Leonardo Galli
parent c1a5e8e759
commit 2139246c4a

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -79,21 +79,24 @@ namespace NzbDrone.Core.MediaFiles
private bool ChangeFileDate(string filePath, DateTime date) private bool ChangeFileDate(string filePath, DateTime date)
{ {
DateTime oldDateTime = _diskProvider.FileGetLastWrite(filePath); DateTime oldDateTime;
if (!DateTime.Equals(date, oldDateTime)) if (DateTime.TryParse(_diskProvider.FileGetLastWrite(filePath).ToLongDateString(), out oldDateTime))
{ {
try if (!DateTime.Equals(date, oldDateTime))
{ {
_diskProvider.FileSetLastWriteTime(filePath, date); try
_logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldDateTime, date); {
_diskProvider.FileSetLastWriteTime(filePath, date);
_logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldDateTime, date);
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.Warn(ex, "Unable to set date of file [" + filePath + "]"); _logger.Warn(ex, "Unable to set date of file [" + filePath + "]");
}
} }
} }

Loading…
Cancel
Save