1
0
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:
Keivan Beigi 2017-01-20 20:15:49 -08:00
parent 5e7e816c03
commit c9a8ebc2e6
No known key found for this signature in database
GPG Key ID: C536675AC49003C0
4 changed files with 30 additions and 3 deletions

View 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());
}
}
}

View File

@ -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" />

View File

@ -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);
}
}
}

View File

@ -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());
}
}
}