Readarr/src/NzbDrone.Common/PathEqualityComparer.cs
Mark McDowall b3cf903a3b New: Improve path validation when handling paths from different OSes
(cherry picked from commit 0321368cc392d7a0a488409bf6bd586ba45497af)

Closes #2309
2023-05-06 15:26:15 +03:00

30 lines
720 B
C#

using System.Collections.Generic;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common
{
public class PathEqualityComparer : IEqualityComparer<string>
{
public static readonly PathEqualityComparer Instance = new PathEqualityComparer();
private PathEqualityComparer()
{
}
public bool Equals(string x, string y)
{
return x.PathEquals(y);
}
public int GetHashCode(string obj)
{
if (OsInfo.IsWindows)
{
return obj.CleanFilePath().ToLower().GetHashCode();
}
return obj.CleanFilePath().GetHashCode();
}
}
}