diff --git a/src/NzbDrone.Api/Extensions/Pipelines/GZipPipeline.cs b/src/NzbDrone.Api/Extensions/Pipelines/GZipPipeline.cs
index 29fb1a7de..a671d1f02 100644
--- a/src/NzbDrone.Api/Extensions/Pipelines/GZipPipeline.cs
+++ b/src/NzbDrone.Api/Extensions/Pipelines/GZipPipeline.cs
@@ -26,7 +26,9 @@ namespace NzbDrone.Api.Extensions.Pipelines
{
try
{
- if (!response.ContentType.Contains("image")
+ if (
+ !response.ContentType.Contains("image")
+ && !response.ContentType.Contains("font")
&& request.Headers.AcceptEncoding.Any(x => x.Contains("gzip"))
&& (!response.Headers.ContainsKey("Content-Encoding") || response.Headers["Content-Encoding"] != "gzip"))
{
diff --git a/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs b/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs
index 47759b5c5..0de2a2622 100644
--- a/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs
+++ b/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs
@@ -51,7 +51,16 @@ namespace NzbDrone.Api.Frontend.Mappers
protected override Stream GetContentStream(string filePath)
{
- return StringToStream(GetIndexText());
+ var text = GetIndexText();
+
+ var stream = new MemoryStream();
+ using (var writer = new StreamWriter(stream))
+ {
+ writer.Write(text);
+ writer.Flush();
+ }
+ stream.Position = 0;
+ return stream;
}
private string GetIndexText()
diff --git a/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs b/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs
index 75cd56180..f0a4acd9d 100644
--- a/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs
+++ b/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs
@@ -51,14 +51,5 @@ namespace NzbDrone.Api.Frontend.Mappers
return File.OpenRead(filePath);
}
- protected static Stream StringToStream(string text)
- {
- var stream = new MemoryStream();
- var writer = new StreamWriter(stream);
- writer.Write(text);
- writer.Flush();
- stream.Position = 0;
- return stream;
- }
}
}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/Crypto/Md5HashProvider.cs b/src/NzbDrone.Common/Crypto/Md5HashProvider.cs
new file mode 100644
index 000000000..e6825c66a
--- /dev/null
+++ b/src/NzbDrone.Common/Crypto/Md5HashProvider.cs
@@ -0,0 +1,26 @@
+using System.Security.Cryptography;
+using NzbDrone.Common.Disk;
+
+namespace NzbDrone.Common.Crypto
+{
+ public class Md5HashProvider
+ {
+ private readonly IDiskProvider _diskProvider;
+
+ public Md5HashProvider(IDiskProvider diskProvider)
+ {
+ _diskProvider = diskProvider;
+ }
+
+ public byte[] ComputeHash(string path)
+ {
+ using (var md5 = MD5.Create())
+ {
+ using (var stream = _diskProvider.StreamFile(path))
+ {
+ return md5.ComputeHash(stream);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/Extensions/Base64Extentions.cs b/src/NzbDrone.Common/Extensions/Base64Extentions.cs
new file mode 100644
index 000000000..3a2dbcf3f
--- /dev/null
+++ b/src/NzbDrone.Common/Extensions/Base64Extentions.cs
@@ -0,0 +1,17 @@
+using System;
+
+namespace NzbDrone.Common.Extensions
+{
+ public static class Base64Extentions
+ {
+ public static string ToBase64(this byte[] bytes)
+ {
+ return Convert.ToBase64String(bytes);
+ }
+
+ public static string ToBase64(this long input)
+ {
+ return BitConverter.GetBytes(input).ToBase64();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/HashUtil.cs b/src/NzbDrone.Common/HashUtil.cs
index abeb9496d..19353f21b 100644
--- a/src/NzbDrone.Common/HashUtil.cs
+++ b/src/NzbDrone.Common/HashUtil.cs
@@ -1,16 +1,10 @@
using System;
using System.Text;
-using System.Threading;
namespace NzbDrone.Common
{
public static class HashUtil
{
- //This should never be changed. very bad things will happen!
- private static readonly DateTime Epoch = new DateTime(2010, 1, 1);
-
- private static readonly object _lock = new object();
-
public static string CalculateCrc(string input)
{
uint mCrc = 0xffffffff;
@@ -32,36 +26,5 @@ namespace NzbDrone.Common
}
return String.Format("{0:x8}", mCrc);
}
-
- public static string GenerateCommandId()
- {
- return GenerateId("c");
- }
-
- private static string GenerateId(string prefix)
- {
- lock (_lock)
- {
- Thread.Sleep(1);
- var tick = (DateTime.Now - Epoch).Ticks;
- return prefix + "." + ToBase(tick);
- }
- }
-
- private static string ToBase(long input)
- {
- const string BASE_CHARS = "0123456789abcdefghijklmnopqrstuvwxyz";
- int targetBase = BASE_CHARS.Length;
-
- var result = new StringBuilder();
- do
- {
- result.Append(BASE_CHARS[(int)(input % targetBase)]);
- input /= targetBase;
- } while (input > 0);
-
- return result.ToString();
- }
-
}
}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj
index bd3053661..c06a5e2a0 100644
--- a/src/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/src/NzbDrone.Common/NzbDrone.Common.csproj
@@ -73,6 +73,7 @@
+
@@ -110,6 +111,7 @@
+