mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 12:32:31 +01:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
d67d89f54a
@ -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<SameFileSpecification>
|
||||||
|
{
|
||||||
|
private LocalMovie _localMovie;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_localMovie = Builder<LocalMovie>.CreateNew()
|
||||||
|
.With(l => l.Size = 150.Megabytes())
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_accepted_if_no_existing_file()
|
||||||
|
{
|
||||||
|
_localMovie.Movie = Builder<Movie>.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<Movie>.CreateNew()
|
||||||
|
.With(e => e.MovieFileId = 1)
|
||||||
|
.With(e => e.MovieFile = new LazyLoaded<MovieFile>(
|
||||||
|
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<Movie>.CreateNew()
|
||||||
|
.With(e => e.MovieFileId = 1)
|
||||||
|
.With(e => e.MovieFile = new LazyLoaded<MovieFile>(
|
||||||
|
new MovieFile
|
||||||
|
{
|
||||||
|
Size = _localMovie.Size
|
||||||
|
}))
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -282,6 +282,7 @@
|
|||||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\MatchesFolderSpecificationFixture.cs" />
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\MatchesFolderSpecificationFixture.cs" />
|
||||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\NotSampleSpecificationFixture.cs" />
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\NotSampleSpecificationFixture.cs" />
|
||||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\NotUnpackingSpecificationFixture.cs" />
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\NotUnpackingSpecificationFixture.cs" />
|
||||||
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\SameFileSpecificationFixture.cs" />
|
||||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\UpgradeSpecificationFixture.cs" />
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\UpgradeSpecificationFixture.cs" />
|
||||||
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
|
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
|
||||||
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
|
<Compile Include="MediaFiles\MediaFileRepositoryFixture.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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,8 +79,10 @@ private bool ChangeFileDate(MovieFile movieFile, Movie movie)
|
|||||||
|
|
||||||
private bool ChangeFileDate(string filePath, DateTime date)
|
private bool ChangeFileDate(string filePath, DateTime date)
|
||||||
{
|
{
|
||||||
DateTime oldDateTime = _diskProvider.FileGetLastWrite(filePath);
|
DateTime oldDateTime;
|
||||||
|
|
||||||
|
if (DateTime.TryParse(_diskProvider.FileGetLastWrite(filePath).ToLongDateString(), out oldDateTime))
|
||||||
|
{
|
||||||
if (!DateTime.Equals(date, oldDateTime))
|
if (!DateTime.Equals(date, oldDateTime))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -96,6 +98,7 @@ private bool ChangeFileDate(string filePath, DateTime date)
|
|||||||
_logger.Warn(ex, "Unable to set date of file [" + filePath + "]");
|
_logger.Warn(ex, "Unable to set date of file [" + filePath + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,7 @@
|
|||||||
<Compile Include="DecisionEngine\Specifications\RequiredIndexerFlagsSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\RequiredIndexerFlagsSpecification.cs" />
|
||||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedAlternativeTitles.cs" />
|
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedAlternativeTitles.cs" />
|
||||||
<Compile Include="MediaFiles\EpisodeImport\Specifications\GrabbedReleaseQualitySpecification.cs" />
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\GrabbedReleaseQualitySpecification.cs" />
|
||||||
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\SameFileSpecification.cs" />
|
||||||
<Compile Include="MediaFiles\Events\MovieFileUpdatedEvent.cs" />
|
<Compile Include="MediaFiles\Events\MovieFileUpdatedEvent.cs" />
|
||||||
<Compile Include="Datastore\Migration\134_add_remux_qualities_for_the_wankers.cs" />
|
<Compile Include="Datastore\Migration\134_add_remux_qualities_for_the_wankers.cs" />
|
||||||
<Compile Include="Datastore\Migration\129_add_parsed_movie_info_to_pending_release.cs" />
|
<Compile Include="Datastore\Migration\129_add_parsed_movie_info_to_pending_release.cs" />
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
.help-inline {
|
.help-inline {
|
||||||
display : inline-block;
|
display : inline-block;
|
||||||
|
margin-top : 8px;
|
||||||
padding-left : 0px;
|
padding-left : 0px;
|
||||||
|
|
||||||
@media (max-width: @screen-xs-max) {
|
@media (max-width: @screen-xs-max) {
|
||||||
|
Loading…
Reference in New Issue
Block a user