diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj
index 260c075a2..58414d8dc 100644
--- a/NzbDrone.Api/NzbDrone.Api.csproj
+++ b/NzbDrone.Api/NzbDrone.Api.csproj
@@ -46,8 +46,7 @@
False
..\packages\Microsoft.AspNet.SignalR.Core.1.1.3\lib\net40\Microsoft.AspNet.SignalR.Core.dll
-
- False
+
..\packages\Nancy.0.18.0\lib\net40\Nancy.dll
diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs
deleted file mode 100644
index aa29dce0a..000000000
--- a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using System.Linq;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Marr.Data;
-using Moq;
-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;
-using NzbDrone.Test.Common;
-
-namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
-{
- [TestFixture]
- public class NotExistingFileSpecificationFixture : CoreTest
- {
- private LocalEpisode _localEpisode;
-
- [SetUp]
- public void Setup()
- {
- _localEpisode = new LocalEpisode
- {
- Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(),
- Size = 100
- };
- }
-
- [Test]
- public void should_return_false_if_path_and_size_are_the_same()
- {
- _localEpisode.Episodes = Builder.CreateListOfSize(1)
- .All()
- .With(e => e.EpisodeFileId = 1)
- .With(e => e.EpisodeFile = new LazyLoaded(
- new EpisodeFile
- {
- Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(),
- Size = 100
- }))
- .Build()
- .ToList();
-
- Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse();
- }
-
- [Test]
- public void should_return_false_if_filename_and_size_are_the_same()
- {
- _localEpisode.Episodes = Builder.CreateListOfSize(1)
- .All()
- .With(e => e.EpisodeFileId = 1)
- .With(e => e.EpisodeFile = new LazyLoaded(
- new EpisodeFile
- {
- Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi".AsOsAgnostic(),
- Size = 100
- }))
- .Build()
- .ToList();
-
- Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse();
- }
-
- [Test]
- public void should_return_true_if_no_existing_file()
- {
- _localEpisode.Episodes = Builder.CreateListOfSize(1)
- .All()
- .With(e => e.EpisodeFileId = 0)
- .Build()
- .ToList();
-
- Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
- }
-
- [Test]
- public void should_return_true_if_size_is_different()
- {
- _localEpisode.Episodes = Builder.CreateListOfSize(1)
- .All()
- .With(e => e.EpisodeFileId = 1)
- .With(e => e.EpisodeFile = new LazyLoaded(
- new EpisodeFile
- {
- Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi".AsOsAgnostic(),
- Size = 50
- }))
- .Build()
- .ToList();
-
- Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
- }
-
- [Test]
- public void should_return_true_if_file_names_are_different()
- {
- _localEpisode.Episodes = Builder.CreateListOfSize(1)
- .All()
- .With(e => e.EpisodeFileId = 1)
- .With(e => e.EpisodeFile = new LazyLoaded(
- new EpisodeFile
- {
- Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi".AsOsAgnostic(),
- Size = 100
- }))
- .Build()
- .ToList();
-
- Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
- }
-
- [Test]
- public void should_return_false_if_exact_path_exists_in_db()
- {
- Mocker.GetMock()
- .Setup(s => s.Exists(It.IsAny()))
- .Returns(true);
-
- _localEpisode.Episodes = Builder.CreateListOfSize(1)
- .All()
- .With(e => e.EpisodeFileId = 1)
- .With(e => e.EpisodeFile = new LazyLoaded(
- new EpisodeFile
- {
- Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi".AsOsAgnostic(),
- Size = 100
- }))
- .Build()
- .ToList();
-
- Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse();
- }
- }
-}
diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs
index 70fae670e..c97082e3d 100644
--- a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs
+++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs
@@ -80,5 +80,30 @@ namespace NzbDrone.Core.Test.MediaFileTests
Subject.FilterExistingFiles(files, 10).Should().HaveCount(2);
Subject.FilterExistingFiles(files, 10).Should().NotContain("c:\\file2.avi".AsOsAgnostic());
}
+
+
+
+
+ [Test]
+ public void filter_should_return_none_existing_files_ignoring_case()
+ {
+ var files = new List()
+ {
+ "c:\\file1.avi".AsOsAgnostic(),
+ "c:\\FILE2.avi".AsOsAgnostic(),
+ "c:\\file3.avi".AsOsAgnostic()
+ };
+
+ Mocker.GetMock()
+ .Setup(c => c.GetFilesBySeries(It.IsAny()))
+ .Returns(new List
+ {
+ new EpisodeFile{Path = "c:\\file2.avi".AsOsAgnostic()}
+ });
+
+
+ Subject.FilterExistingFiles(files, 10).Should().HaveCount(2);
+ Subject.FilterExistingFiles(files, 10).Should().NotContain("c:\\file2.avi".AsOsAgnostic());
+ }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs
index 9f2b468b7..833e368a3 100644
--- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs
+++ b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs
@@ -1,9 +1,7 @@
using System;
using System.IO;
-using System.Linq;
using NLog;
using NzbDrone.Common;
-using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotExistingFileSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotExistingFileSpecification.cs
deleted file mode 100644
index ec335345d..000000000
--- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotExistingFileSpecification.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.IO;
-using System.Linq;
-using NLog;
-using NzbDrone.Core.Parser.Model;
-
-namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
-{
- public class NotExistingFileSpecification : IImportDecisionEngineSpecification
- {
- private readonly IMediaFileService _mediaFileService;
- private readonly Logger _logger;
-
- public NotExistingFileSpecification(IMediaFileService mediaFileService, Logger logger)
- {
- _mediaFileService = mediaFileService;
- _logger = logger;
- }
-
- public string RejectionReason { get { return "Existing File"; } }
-
- public bool IsSatisfiedBy(LocalEpisode localEpisode)
- {
- if (_mediaFileService.Exists(localEpisode.Path))
- {
- _logger.Trace("File is a match for an existing episode file: {0}", localEpisode.Path);
- return false;
- }
-
- var existingFiles = localEpisode.Episodes.Where(e => e.EpisodeFileId > 0).Select(e => e.EpisodeFile.Value);
-
- foreach (var existingFile in existingFiles)
- {
- if (Path.GetFileName(existingFile.Path) == Path.GetFileName(localEpisode.Path) &&
- existingFile.Size == localEpisode.Size)
- {
- _logger.Trace("File is a match for an existing episode file: {0}", localEpisode.Path);
- return false;
- }
- }
-
- return true;
- }
- }
-}
diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotInUseSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotInUseSpecification.cs
index 32d1a1cee..5fd2f453b 100644
--- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotInUseSpecification.cs
+++ b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotInUseSpecification.cs
@@ -1,9 +1,7 @@
using System.IO;
-using System.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Parser.Model;
-using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
{
diff --git a/NzbDrone.Core/MediaFiles/MediaFileService.cs b/NzbDrone.Core/MediaFiles/MediaFileService.cs
index 09dc47986..784a09c02 100644
--- a/NzbDrone.Core/MediaFiles/MediaFileService.cs
+++ b/NzbDrone.Core/MediaFiles/MediaFileService.cs
@@ -4,6 +4,7 @@ using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Tv.Events;
+using NzbDrone.Common;
namespace NzbDrone.Core.MediaFiles
{
@@ -73,11 +74,11 @@ namespace NzbDrone.Core.MediaFiles
public List FilterExistingFiles(List files, int seriesId)
{
- var seriesFiles = GetFilesBySeries(seriesId);
+ var seriesFiles = GetFilesBySeries(seriesId).Select(f => f.Path.CleanFilePath().ToLower()).ToList();
if (!seriesFiles.Any()) return files;
- return files.Select(f => f.Normalize()).Except(seriesFiles.Select(c => c.Path)).ToList();
+ return files.Select(f => f.CleanFilePath().ToLower()).Except(seriesFiles).ToList();
}
public void HandleAsync(SeriesDeletedEvent message)
diff --git a/NzbDrone.Host/NzbDrone.Host.csproj b/NzbDrone.Host/NzbDrone.Host.csproj
index a47abc8ed..2eb6bcda7 100644
--- a/NzbDrone.Host/NzbDrone.Host.csproj
+++ b/NzbDrone.Host/NzbDrone.Host.csproj
@@ -89,8 +89,7 @@
False
..\packages\Microsoft.Owin.Hosting.1.1.0-beta2\lib\net40\Microsoft.Owin.Hosting.dll
-
- False
+
..\packages\Nancy.0.18.0\lib\net40\Nancy.dll