From 743754a041d93fe0c9074701df0bd9a3995abdb1 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 20 Oct 2013 11:17:56 -0700 Subject: [PATCH] Catch any errors setting last write time so we don't blow up the whole process Fixed: Prevent error when importing files that causes the process to fail --- .../MediaFiles/EpisodeFileMovingService.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs index 5981475a0..43c018656 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using Growl.Connector; using NLog; using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; @@ -74,15 +75,23 @@ private void MoveFile(EpisodeFile episodeFile, Series series, string destination _logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, destinationFilename); _diskProvider.MoveFile(episodeFile.Path, destinationFilename); - _logger.Trace("Setting last write time on series folder: {0}", series.Path); - _diskProvider.SetFolderWriteTime(series.Path, episodeFile.DateAdded); - - if (series.SeasonFolder) + try { - var seasonFolder = Path.GetDirectoryName(destinationFilename); + _logger.Trace("Setting last write time on series folder: {0}", series.Path); + _diskProvider.SetFolderWriteTime(series.Path, episodeFile.DateAdded); - _logger.Trace("Setting last write time on season folder: {0}", seasonFolder); - _diskProvider.SetFolderWriteTime(seasonFolder, episodeFile.DateAdded); + if (series.SeasonFolder) + { + var seasonFolder = Path.GetDirectoryName(destinationFilename); + + _logger.Trace("Setting last write time on season folder: {0}", seasonFolder); + _diskProvider.SetFolderWriteTime(seasonFolder, episodeFile.DateAdded); + } + } + + catch (Exception ex) + { + _logger.WarnException("Unable to set last write time", ex); } //We should only run this on Windows