mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Create anonymous hash to detect issue duplication
This commit is contained in:
parent
5e7e816c03
commit
c9a8ebc2e6
21
src/NzbDrone.Common.Test/HashUtilFixture.cs
Normal file
21
src/NzbDrone.Common.Test/HashUtilFixture.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class HashUtilFixture
|
||||
{
|
||||
[Test]
|
||||
public void should_create_anon_id()
|
||||
{
|
||||
HashUtil.AnonymousToken().Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_create_the_same_id()
|
||||
{
|
||||
HashUtil.AnonymousToken().Should().Be(HashUtil.AnonymousToken());
|
||||
}
|
||||
}
|
||||
}
|
@ -84,6 +84,7 @@
|
||||
<Compile Include="ExtensionTests\IEnumerableExtensionTests\ExceptByFixture.cs" />
|
||||
<Compile Include="ExtensionTests\IEnumerableExtensionTests\IntersectByFixture.cs" />
|
||||
<Compile Include="ExtensionTests\Int64ExtensionFixture.cs" />
|
||||
<Compile Include="HashUtilFixture.cs" />
|
||||
<Compile Include="Http\HttpClientFixture.cs" />
|
||||
<Compile Include="Http\HttpHeaderFixture.cs" />
|
||||
<Compile Include="Http\HttpRequestBuilderFixture.cs" />
|
||||
|
@ -24,7 +24,13 @@ public static string CalculateCrc(string input)
|
||||
}
|
||||
}
|
||||
}
|
||||
return string.Format("{0:x8}", mCrc);
|
||||
return $"{mCrc:x8}";
|
||||
}
|
||||
|
||||
public static string AnonymousToken()
|
||||
{
|
||||
var seed = $"{Environment.ProcessorCount}_{Environment.OSVersion.Platform}_{Environment.MachineName}_{Environment.UserName}";
|
||||
return HashUtil.CalculateCrc(seed);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using SharpRaven.Data;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation.Sentry
|
||||
@ -7,7 +6,7 @@ public class MachineNameUserFactory : ISentryUserFactory
|
||||
{
|
||||
public SentryUser Create()
|
||||
{
|
||||
return new SentryUser(Environment.MachineName);
|
||||
return new SentryUser(HashUtil.AnonymousToken());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user