mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
FilterExistingFiles no longer converts paths to all lower case
This commit is contained in:
parent
e7b329a618
commit
0d6b9969d2
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
@ -14,7 +15,12 @@ public bool Equals(string x, string y)
|
||||
|
||||
public int GetHashCode(string obj)
|
||||
{
|
||||
return obj.CleanFilePath().GetHashCode();
|
||||
if (OsInfo.IsLinux)
|
||||
{
|
||||
return obj.CleanFilePath().GetHashCode();
|
||||
}
|
||||
|
||||
return obj.CleanFilePath().ToLower().GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,11 @@ public void filter_should_return_none_existing_files()
|
||||
Subject.FilterExistingFiles(files, 10).Should().NotContain("c:\\file2.avi".AsOsAgnostic());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void filter_should_return_none_existing_files_ignoring_case()
|
||||
{
|
||||
WindowsOnly();
|
||||
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
@ -105,5 +104,44 @@ public void filter_should_return_none_existing_files_ignoring_case()
|
||||
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_not_ignoring_case()
|
||||
{
|
||||
LinuxOnly();
|
||||
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\file1.avi".AsOsAgnostic(),
|
||||
"c:\\FILE2.avi".AsOsAgnostic(),
|
||||
"c:\\file3.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>
|
||||
{
|
||||
new EpisodeFile{Path = "c:\\file2.avi".AsOsAgnostic()}
|
||||
});
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().HaveCount(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void filter_should_not_change_casing()
|
||||
{
|
||||
var files = new List<string>()
|
||||
{
|
||||
"c:\\FILE1.avi".AsOsAgnostic()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileRepository>()
|
||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
Subject.FilterExistingFiles(files, 10).Should().HaveCount(1);
|
||||
Subject.FilterExistingFiles(files, 10).Should().NotContain(files.First().ToLower());
|
||||
Subject.FilterExistingFiles(files, 10).Should().Contain(files.First());
|
||||
}
|
||||
}
|
||||
}
|
@ -76,11 +76,11 @@ public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
||||
|
||||
public List<string> FilterExistingFiles(List<string> files, int seriesId)
|
||||
{
|
||||
var seriesFiles = GetFilesBySeries(seriesId).Select(f => f.Path.CleanFilePath().ToLower()).ToList();
|
||||
var seriesFiles = GetFilesBySeries(seriesId).Select(f => f.Path.CleanFilePath()).ToList();
|
||||
|
||||
if (!seriesFiles.Any()) return files;
|
||||
|
||||
return files.Select(f => f.CleanFilePath().ToLower()).Except(seriesFiles).ToList();
|
||||
return files.Select(f => f.CleanFilePath()).Except(seriesFiles, new PathEqualityComparer()).ToList();
|
||||
}
|
||||
|
||||
public EpisodeFile Get(int id)
|
||||
|
Loading…
Reference in New Issue
Block a user