From 2139246c4a1de85f6049604a2d5ed766575a7ecb Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Feb 2018 15:06:26 +0100 Subject: [PATCH 1/3] 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 @@ private bool ChangeFileDate(MovieFile movieFile, Movie movie) 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 + "]"); + } } } From 4dc36123475ab489af2019f20df25dda23c8c023 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Feb 2018 15:06:53 +0100 Subject: [PATCH 2/3] Fixed: Help icon not centered (#2531) Fixes #2528 --- src/UI/Content/form.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/UI/Content/form.less b/src/UI/Content/form.less index 4632e40f2..58c80d190 100644 --- a/src/UI/Content/form.less +++ b/src/UI/Content/form.less @@ -41,6 +41,7 @@ .help-inline { display : inline-block; + margin-top : 8px; padding-left : 0px; @media (max-width: @screen-xs-max) { From 0c23511b7ad7b6ca0f35416f512bdea8dff2d757 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Feb 2018 17:29:41 +0100 Subject: [PATCH 3/3] Added: Same File Size MediaFile Specification (#2532) --- .../SameFileSpecificationFixture.cs | 67 +++++++++++++++++++ .../NzbDrone.Core.Test.csproj | 1 + .../Specifications/SameFileSpecification.cs | 42 ++++++++++++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 4 files changed, 111 insertions(+) create mode 100644 src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs create mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs new file mode 100644 index 000000000..41b36d971 --- /dev/null +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs @@ -0,0 +1,67 @@ +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using Marr.Data; +using NUnit.Framework; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications +{ + [TestFixture] + public class SameFileSpecificationFixture : CoreTest + { + private LocalMovie _localMovie; + + [SetUp] + public void Setup() + { + _localMovie = Builder.CreateNew() + .With(l => l.Size = 150.Megabytes()) + .Build(); + } + + [Test] + public void should_be_accepted_if_no_existing_file() + { + _localMovie.Movie = Builder.CreateNew() + .With(e => e.MovieFileId = 0) + .Build(); + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_be_accepted_if_file_size_is_different() + { + _localMovie.Movie = Builder.CreateNew() + .With(e => e.MovieFileId = 1) + .With(e => e.MovieFile = new LazyLoaded( + new MovieFile + { + Size = _localMovie.Size + 100.Megabytes() + })) + .Build(); + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_be_reject_if_file_size_is_the_same() + { + _localMovie.Movie = Builder.CreateNew() + .With(e => e.MovieFileId = 1) + .With(e => e.MovieFile = new LazyLoaded( + new MovieFile + { + Size = _localMovie.Size + })) + .Build(); + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); + } + } +} diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a56079e96..e2f3ade60 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -283,6 +283,7 @@ + diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs new file mode 100644 index 000000000..7eeb93684 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs @@ -0,0 +1,42 @@ +using System.Linq; +using NLog; +using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Download; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications +{ + public class SameFileSpecification : IImportDecisionEngineSpecification + { + private readonly Logger _logger; + + public SameFileSpecification(Logger logger) + { + _logger = logger; + } + + public Decision IsSatisfiedBy(LocalEpisode localEpisode) + { + return Decision.Accept(); + } + + public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) + { + var movieFile = localMovie.Movie.MovieFile; + + if (localMovie.Movie.MovieFileId == 0) + { + _logger.Debug("No existing movie file, skipping"); + return Decision.Accept(); + } + + if (movieFile.Size == localMovie.Size) + { + _logger.Debug("'{0}' Has the same filesize as existing file", localMovie.Path); + return Decision.Reject("Has the same filesize as existing file"); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index bf3bb5215..7d6e50944 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -131,6 +131,7 @@ +