From 2139246c4a1de85f6049604a2d5ed766575a7ecb Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Feb 2018 15:06:26 +0100 Subject: [PATCH] Fixed: Radarr Changes every file due to timezones (#2533) Fixes #1741 --- .../MediaFiles/UpdateMovieFileService.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs b/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs index 4c40f6b1e..a75679a31 100644 --- a/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -79,21 +79,24 @@ namespace NzbDrone.Core.MediaFiles 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); - _logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldDateTime, date); + try + { + _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) - { - _logger.Warn(ex, "Unable to set date of file [" + filePath + "]"); + catch (Exception ex) + { + _logger.Warn(ex, "Unable to set date of file [" + filePath + "]"); + } } }