mirror of https://github.com/lidarr/Lidarr
Use 'var' instead of explicit type
(cherry picked from commit 12374f7f0038e5b25548f5ab3f71122410832393) Closes #3749
This commit is contained in:
parent
14816306a4
commit
cc27107668
|
@ -32,7 +32,7 @@ namespace Lidarr.Api.V1.Logs
|
|||
|
||||
var files = GetLogFiles().ToList();
|
||||
|
||||
for (int i = 0; i < files.Count; i++)
|
||||
for (var i = 0; i < files.Count; i++)
|
||||
{
|
||||
var file = files[i];
|
||||
var filename = Path.GetFileName(file);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
|||
[HttpGet]
|
||||
public QualityProfileResource GetSchema()
|
||||
{
|
||||
QualityProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||
var qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||
|
||||
return qualityProfile.ToResource();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Lidarr.Api.V1.Search
|
|||
|
||||
private static IEnumerable<SearchResource> MapToResource(IEnumerable<object> results)
|
||||
{
|
||||
int id = 1;
|
||||
var id = 1;
|
||||
foreach (var result in results)
|
||||
{
|
||||
var resource = new SearchResource();
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Lidarr.Api.V1.TrackFiles
|
|||
return 0;
|
||||
}
|
||||
|
||||
int qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
|
||||
var qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
|
||||
qualityWeight += quality.Revision.Real * 10;
|
||||
qualityWeight += quality.Revision.Version;
|
||||
return qualityWeight;
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Lidarr.Http.ClientSchema
|
|||
result = GetFieldMapping(type, "", v => v);
|
||||
|
||||
// Renumber al the field Orders since nested settings will have dupe Orders.
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
for (var i = 0; i < result.Length; i++)
|
||||
{
|
||||
result[i].Field.Order = i;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace NzbDrone.Automation.Test
|
|||
{
|
||||
try
|
||||
{
|
||||
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
|
||||
var image = ((ITakesScreenshot)driver).GetScreenshot();
|
||||
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace NzbDrone.Automation.Test.PageModel
|
|||
{
|
||||
try
|
||||
{
|
||||
IWebElement element = d.FindElement(By.ClassName("followingBalls"));
|
||||
var element = d.FindElement(By.ClassName("followingBalls"));
|
||||
return !element.Displayed;
|
||||
}
|
||||
catch (NoSuchElementException)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
@ -65,9 +65,9 @@ namespace NzbDrone.Common.Test.CacheTests
|
|||
[Test]
|
||||
public void should_store_null()
|
||||
{
|
||||
int hitCount = 0;
|
||||
var hitCount = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
_cachedString.Get("key", () =>
|
||||
{
|
||||
|
@ -83,10 +83,10 @@ namespace NzbDrone.Common.Test.CacheTests
|
|||
[Platform(Exclude = "MacOsX")]
|
||||
public void should_honor_ttl()
|
||||
{
|
||||
int hitCount = 0;
|
||||
var hitCount = 0;
|
||||
_cachedString = new Cached<string>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
_cachedString.Get("key",
|
||||
() =>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -142,7 +142,7 @@ namespace NzbDrone.Common.Test
|
|||
[Test]
|
||||
public void SaveDictionary_should_save_proper_value()
|
||||
{
|
||||
int port = 20555;
|
||||
var port = 20555;
|
||||
|
||||
var dic = Subject.GetConfigDictionary();
|
||||
dic["Port"] = 20555;
|
||||
|
@ -155,9 +155,9 @@ namespace NzbDrone.Common.Test
|
|||
[Test]
|
||||
public void SaveDictionary_should_only_save_specified_values()
|
||||
{
|
||||
int port = 20555;
|
||||
int origSslPort = 20551;
|
||||
int sslPort = 20552;
|
||||
var port = 20555;
|
||||
var origSslPort = 20551;
|
||||
var sslPort = 20552;
|
||||
|
||||
var dic = Subject.GetConfigDictionary();
|
||||
dic["Port"] = port;
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
|||
[Test]
|
||||
public void should_not_contain_recycling_bin_for_root_of_drive()
|
||||
{
|
||||
string root = @"C:\".AsOsAgnostic();
|
||||
var root = @"C:\".AsOsAgnostic();
|
||||
SetupFolders(root);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -56,7 +56,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
|||
[Test]
|
||||
public void should_not_contain_system_volume_information()
|
||||
{
|
||||
string root = @"C:\".AsOsAgnostic();
|
||||
var root = @"C:\".AsOsAgnostic();
|
||||
SetupFolders(root);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -69,7 +69,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
|||
[Test]
|
||||
public void should_not_contain_recycling_bin_or_system_volume_information_for_root_of_drive()
|
||||
{
|
||||
string root = @"C:\".AsOsAgnostic();
|
||||
var root = @"C:\".AsOsAgnostic();
|
||||
SetupFolders(root);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
|
|
@ -800,7 +800,7 @@ namespace NzbDrone.Common.Test.Http
|
|||
try
|
||||
{
|
||||
// the date is bad in the below - should be 13-Jul-2026
|
||||
string malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
|
||||
var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
|
||||
var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers")
|
||||
.AddQueryParam("Set-Cookie", malformedCookie)
|
||||
.Build();
|
||||
|
@ -834,7 +834,7 @@ namespace NzbDrone.Common.Test.Http
|
|||
{
|
||||
try
|
||||
{
|
||||
string url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
|
||||
var url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
|
||||
|
||||
var requestSet = new HttpRequest(url);
|
||||
requestSet.AllowAutoRedirect = false;
|
||||
|
|
|
@ -74,17 +74,17 @@ namespace NzbDrone.Common
|
|||
continue; // Ignore directories
|
||||
}
|
||||
|
||||
string entryFileName = zipEntry.Name;
|
||||
var entryFileName = zipEntry.Name;
|
||||
|
||||
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
|
||||
// Optionally match entrynames against a selection list here to skip as desired.
|
||||
// The unpacked length is available in the zipEntry.Size property.
|
||||
byte[] buffer = new byte[4096]; // 4K is optimum
|
||||
Stream zipStream = zipFile.GetInputStream(zipEntry);
|
||||
var buffer = new byte[4096]; // 4K is optimum
|
||||
var zipStream = zipFile.GetInputStream(zipEntry);
|
||||
|
||||
// Manipulate the output filename here as desired.
|
||||
string fullZipToPath = Path.Combine(destination, entryFileName);
|
||||
string directoryName = Path.GetDirectoryName(fullZipToPath);
|
||||
var fullZipToPath = Path.Combine(destination, entryFileName);
|
||||
var directoryName = Path.GetDirectoryName(fullZipToPath);
|
||||
if (directoryName.Length > 0)
|
||||
{
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Common
|
|||
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
|
||||
// of the file, but does not waste memory.
|
||||
// The "using" will close the stream even if an exception occurs.
|
||||
using (FileStream streamWriter = File.Create(fullZipToPath))
|
||||
using (var streamWriter = File.Create(fullZipToPath))
|
||||
{
|
||||
StreamUtils.Copy(zipStream, streamWriter, buffer);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Common
|
|||
Stream inStream = File.OpenRead(compressedFile);
|
||||
Stream gzipStream = new GZipInputStream(inStream);
|
||||
|
||||
TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
|
||||
var tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
|
||||
tarArchive.ExtractContents(destination);
|
||||
tarArchive.Close();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace NzbDrone.Common
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public static class ConvertBase32
|
||||
{
|
||||
|
@ -6,17 +6,17 @@
|
|||
|
||||
public static byte[] FromBase32String(string str)
|
||||
{
|
||||
int numBytes = str.Length * 5 / 8;
|
||||
byte[] bytes = new byte[numBytes];
|
||||
var numBytes = str.Length * 5 / 8;
|
||||
var bytes = new byte[numBytes];
|
||||
|
||||
// all UPPERCASE chars
|
||||
str = str.ToUpper();
|
||||
|
||||
int bitBuffer = 0;
|
||||
int bitBufferCount = 0;
|
||||
int index = 0;
|
||||
var bitBuffer = 0;
|
||||
var bitBufferCount = 0;
|
||||
var index = 0;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
for (var i = 0; i < str.Length; i++)
|
||||
{
|
||||
bitBuffer = (bitBuffer << 5) | ValidChars.IndexOf(str[i]);
|
||||
bitBufferCount += 5;
|
||||
|
|
|
@ -255,7 +255,7 @@ namespace NzbDrone.Common.Disk
|
|||
|
||||
var stringComparison = (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows) ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;
|
||||
|
||||
for (int i = 0; i < leftFragments.Length; i++)
|
||||
for (var i = 0; i < leftFragments.Length; i++)
|
||||
{
|
||||
if (!string.Equals(leftFragments[i], rightFragments[i], stringComparison))
|
||||
{
|
||||
|
@ -372,12 +372,12 @@ namespace NzbDrone.Common.Disk
|
|||
|
||||
var newFragments = new List<string>();
|
||||
|
||||
for (int j = i; j < rightFragments.Length; j++)
|
||||
for (var j = i; j < rightFragments.Length; j++)
|
||||
{
|
||||
newFragments.Add("..");
|
||||
}
|
||||
|
||||
for (int j = i; j < leftFragments.Length; j++)
|
||||
for (var j = i; j < leftFragments.Length; j++)
|
||||
{
|
||||
newFragments.Add(leftFragments[j]);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
@ -107,7 +107,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
|
||||
private static string RunAndCapture(string filename, string args)
|
||||
{
|
||||
Process p = new Process();
|
||||
var p = new Process();
|
||||
p.StartInfo.FileName = filename;
|
||||
p.StartInfo.Arguments = args;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
|
@ -117,7 +117,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
p.Start();
|
||||
|
||||
// To avoid deadlocks, always read the output stream first and then wait.
|
||||
string output = p.StandardOutput.ReadToEnd();
|
||||
var output = p.StandardOutput.ReadToEnd();
|
||||
p.WaitForExit(1000);
|
||||
|
||||
return output;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ namespace NzbDrone.Common.Extensions
|
|||
private static Tuple<int, double> match_bitap(string text, string pattern, double matchThreshold)
|
||||
{
|
||||
// Initialise the alphabet.
|
||||
Dictionary<char, BigInteger> s = alphabet(pattern);
|
||||
var s = alphabet(pattern);
|
||||
|
||||
// don't keep creating new BigInteger(1)
|
||||
var big1 = new BigInteger(1);
|
||||
|
@ -88,19 +88,19 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
// Initialise the bit arrays.
|
||||
var matchmask = big1 << (pattern.Length - 1);
|
||||
int best_loc = -1;
|
||||
var best_loc = -1;
|
||||
|
||||
// Empty initialization added to appease C# compiler.
|
||||
var last_rd = Array.Empty<BigInteger>();
|
||||
for (int d = 0; d < pattern.Length; d++)
|
||||
for (var d = 0; d < pattern.Length; d++)
|
||||
{
|
||||
// Scan for the best match; each iteration allows for one more error.
|
||||
int start = 1;
|
||||
int finish = text.Length + pattern.Length;
|
||||
var start = 1;
|
||||
var finish = text.Length + pattern.Length;
|
||||
|
||||
var rd = new BigInteger[finish + 2];
|
||||
rd[finish + 1] = (big1 << d) - big1;
|
||||
for (int j = finish; j >= start; j--)
|
||||
for (var j = finish; j >= start; j--)
|
||||
{
|
||||
BigInteger charMatch;
|
||||
if (text.Length <= j - 1 || !s.ContainsKey(text[j - 1]))
|
||||
|
@ -171,8 +171,8 @@ namespace NzbDrone.Common.Extensions
|
|||
private static Dictionary<char, BigInteger> alphabet(string pattern)
|
||||
{
|
||||
var s = new Dictionary<char, BigInteger>();
|
||||
char[] char_pattern = pattern.ToCharArray();
|
||||
foreach (char c in char_pattern)
|
||||
var char_pattern = pattern.ToCharArray();
|
||||
foreach (var c in char_pattern)
|
||||
{
|
||||
if (!s.ContainsKey(c))
|
||||
{
|
||||
|
@ -180,8 +180,8 @@ namespace NzbDrone.Common.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (char c in char_pattern)
|
||||
var i = 0;
|
||||
foreach (var c in char_pattern)
|
||||
{
|
||||
s[c] = s[c] | (new BigInteger(1) << (pattern.Length - i - 1));
|
||||
i++;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace NzbDrone.Common.Extensions
|
|||
return text.Length * costDelete;
|
||||
}
|
||||
|
||||
int[] matrix = new int[other.Length + 1];
|
||||
var matrix = new int[other.Length + 1];
|
||||
|
||||
for (var i = 1; i < matrix.Length; i++)
|
||||
{
|
||||
|
@ -30,13 +30,13 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
for (var i = 0; i < text.Length; i++)
|
||||
{
|
||||
int topLeft = matrix[0];
|
||||
var topLeft = matrix[0];
|
||||
matrix[0] = matrix[0] + costDelete;
|
||||
|
||||
for (var j = 0; j < other.Length; j++)
|
||||
{
|
||||
int top = matrix[j];
|
||||
int left = matrix[j + 1];
|
||||
var top = matrix[j];
|
||||
var left = matrix[j + 1];
|
||||
|
||||
var sumIns = top + costInsert;
|
||||
var sumDel = left + costDelete;
|
||||
|
|
|
@ -244,13 +244,13 @@ namespace NzbDrone.Common.Extensions
|
|||
var firstPath = paths.First();
|
||||
var length = firstPath.Length;
|
||||
|
||||
for (int i = 1; i < paths.Count; i++)
|
||||
for (var i = 1; i < paths.Count; i++)
|
||||
{
|
||||
var path = paths[i];
|
||||
|
||||
length = Math.Min(length, path.Length);
|
||||
|
||||
for (int characterIndex = 0; characterIndex < length; characterIndex++)
|
||||
for (var characterIndex = 0; characterIndex < length; characterIndex++)
|
||||
{
|
||||
if (path[characterIndex] != firstPath[characterIndex])
|
||||
{
|
||||
|
|
|
@ -188,11 +188,11 @@ namespace NzbDrone.Common.Extensions
|
|||
{
|
||||
double weightDenom = Math.Max(a.Length, b.Length);
|
||||
double sum = 0;
|
||||
for (int i = 0; i < a.Length; i++)
|
||||
for (var i = 0; i < a.Length; i++)
|
||||
{
|
||||
double high = 0.0;
|
||||
int indexDistance = 0;
|
||||
for (int x = 0; x < b.Length; x++)
|
||||
var high = 0.0;
|
||||
var indexDistance = 0;
|
||||
for (var x = 0; x < b.Length; x++)
|
||||
{
|
||||
var coef = LevenshteinCoefficient(a[i], b[x]);
|
||||
if (coef > high)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
|
@ -7,9 +7,9 @@ namespace NzbDrone.Common
|
|||
{
|
||||
public static string CalculateCrc(string input)
|
||||
{
|
||||
uint mCrc = 0xffffffff;
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(input);
|
||||
foreach (byte myByte in bytes)
|
||||
var mCrc = 0xffffffff;
|
||||
var bytes = Encoding.UTF8.GetBytes(input);
|
||||
foreach (var myByte in bytes)
|
||||
{
|
||||
mCrc ^= (uint)myByte << 24;
|
||||
for (var i = 0; i < 8; i++)
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Common.Http
|
|||
|
||||
public HttpUri(string scheme, string host, int? port, string path, string query, string fragment)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
|
||||
if (scheme.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Common.Http.Proxy
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Common.Http.Proxy
|
|||
if (!string.IsNullOrWhiteSpace(BypassFilter))
|
||||
{
|
||||
var hostlist = BypassFilter.Split(',');
|
||||
for (int i = 0; i < hostlist.Length; i++)
|
||||
for (var i = 0; i < hostlist.Length; i++)
|
||||
{
|
||||
if (hostlist[i].StartsWith("*"))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
|
@ -16,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
}
|
||||
}
|
||||
|
||||
foreach (JToken token in json)
|
||||
foreach (var token in json)
|
||||
{
|
||||
Visit(token);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
|
||||
private static void RegisterDebugger()
|
||||
{
|
||||
DebuggerTarget target = new DebuggerTarget();
|
||||
var target = new DebuggerTarget();
|
||||
target.Name = "debuggerLogger";
|
||||
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NzbDrone.Common.Serializer
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Common.Serializer
|
|||
|
||||
public virtual void Visit(JArray json)
|
||||
{
|
||||
foreach (JToken token in json)
|
||||
foreach (var token in json)
|
||||
{
|
||||
Visit(token);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace NzbDrone.Common.Serializer
|
|||
|
||||
public virtual void Visit(JObject json)
|
||||
{
|
||||
foreach (JProperty property in json.Properties())
|
||||
foreach (var property in json.Properties())
|
||||
{
|
||||
Visit(property);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace NzbDrone.Common.Serializer
|
|||
var enumText = value.ToString();
|
||||
var builder = new StringBuilder(enumText.Length + 4);
|
||||
builder.Append(char.ToLower(enumText[0]));
|
||||
for (int i = 1; i < enumText.Length; i++)
|
||||
for (var i = 1; i < enumText.Length; i++)
|
||||
{
|
||||
if (char.IsUpper(enumText[i]))
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Common.Serializer
|
|||
{
|
||||
try
|
||||
{
|
||||
Version v = new Version(reader.GetString());
|
||||
var v = new Version(reader.GetString());
|
||||
return v;
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace NzbDrone.Common.TPL
|
|||
/// <returns>An enumerable of the tasks currently scheduled.</returns>
|
||||
protected sealed override IEnumerable<Task> GetScheduledTasks()
|
||||
{
|
||||
bool lockTaken = false;
|
||||
var lockTaken = false;
|
||||
try
|
||||
{
|
||||
Monitor.TryEnter(_tasks, ref lockTaken);
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace NzbDrone.Console
|
|||
}
|
||||
|
||||
System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
|
||||
for (int i = 0; i < 3600; i++)
|
||||
for (var i = 0; i < 3600; i++)
|
||||
{
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
Subject.SetFields(_basicList, x => x.Interval);
|
||||
|
||||
for (int i = 0; i < _basicList.Count; i++)
|
||||
for (var i = 0; i < _basicList.Count; i++)
|
||||
{
|
||||
_basicList[i].LastExecution = executionBackup[i];
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
|||
|
||||
private void GivenTracks(add_release_groups_etc c, int artistid, int albumid, int firstId, int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var id = firstId + i;
|
||||
c.Insert.IntoTable("Tracks").Row(new
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
|||
|
||||
private void GivenTrackFiles(add_mediafilerepository_mtime c, List<string> tracks, int albumReleaseId, int albumId, int firstId = 1, bool addTracks = true)
|
||||
{
|
||||
int id = firstId;
|
||||
var id = firstId;
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
c.Insert.IntoTable("TrackFiles").Row(new
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
var profile = new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.MP3_320.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
|
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
var profile = new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.FLAC_24.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
VerifySingleItem(DownloadItemStatus.Downloading);
|
||||
|
||||
// If we keep changing the file every 20ms we should stay Downloading.
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
TestLogger.Info("Iteration {0}", i);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test
|
|||
[Test]
|
||||
public void ToBestDateTime_DayOfWeek()
|
||||
{
|
||||
for (int i = 2; i < 7; i++)
|
||||
for (var i = 2; i < 7; i++)
|
||||
{
|
||||
var dateTime = DateTime.Today.AddDays(i);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
[Test]
|
||||
public void should_return_ok_if_not_downloading_to_root_folder()
|
||||
{
|
||||
string rootFolderPath = "c:\\Test2".AsOsAgnostic();
|
||||
var rootFolderPath = "c:\\Test2".AsOsAgnostic();
|
||||
|
||||
GivenRootFolder(rootFolderPath);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.Instrumentation
|
|||
public void write_long_log()
|
||||
{
|
||||
var message = string.Empty;
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
message += Guid.NewGuid();
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
|
|||
{
|
||||
get
|
||||
{
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
|
||||
foreach (var tokens in tokenList)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
|
|||
private List<string> GivenFilenames(string[] fields, string fieldSeparator, string whitespace)
|
||||
{
|
||||
var outp = new List<string>();
|
||||
for (int i = 1; i <= 3; i++)
|
||||
for (var i = 1; i <= 3; i++)
|
||||
{
|
||||
var components = new List<string>();
|
||||
foreach (var field in fields)
|
||||
|
@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
|
|||
|
||||
private void VerifyDataAuto(List<LocalTrack> tracks, string[] tokens, string whitespace)
|
||||
{
|
||||
for (int i = 1; i <= tracks.Count; i++)
|
||||
for (var i = 1; i <= tracks.Count; i++)
|
||||
{
|
||||
var info = tracks[i - 1].FileTrackInfo;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
.Build()
|
||||
.ToList();
|
||||
|
||||
for (int i = 0; i < tracks.Count; i++)
|
||||
for (var i = 0; i < tracks.Count; i++)
|
||||
{
|
||||
output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
Mocker.SetConstant<ICandidateService>(Mocker.Resolve<CandidateService>());
|
||||
|
||||
// set up the augmenters
|
||||
List<IAggregate<LocalAlbumRelease>> aggregators = new List<IAggregate<LocalAlbumRelease>>
|
||||
var aggregators = new List<IAggregate<LocalAlbumRelease>>
|
||||
{
|
||||
Mocker.Resolve<AggregateFilenameInfo>()
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
private List<Artist> GivenArtists(List<ArtistTestCase> artists)
|
||||
{
|
||||
var outp = new List<Artist>();
|
||||
for (int i = 0; i < artists.Count; i++)
|
||||
for (var i = 0; i < artists.Count; i++)
|
||||
{
|
||||
var meta = artists[i].MetadataProfile;
|
||||
meta.Id = i + 1;
|
||||
|
|
|
@ -30,17 +30,17 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
static RandomValueNamerShortStrings()
|
||||
{
|
||||
AllowedChars = new List<char>();
|
||||
for (char c = 'a'; c < 'z'; c++)
|
||||
for (var c = 'a'; c < 'z'; c++)
|
||||
{
|
||||
AllowedChars.Add(c);
|
||||
}
|
||||
|
||||
for (char c = 'A'; c < 'Z'; c++)
|
||||
for (var c = 'A'; c < 'Z'; c++)
|
||||
{
|
||||
AllowedChars.Add(c);
|
||||
}
|
||||
|
||||
for (char c = '0'; c < '9'; c++)
|
||||
for (var c = '0'; c < '9'; c++)
|
||||
{
|
||||
AllowedChars.Add(c);
|
||||
}
|
||||
|
@ -48,17 +48,17 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
|
||||
protected override string GetString(MemberInfo memberInfo)
|
||||
{
|
||||
int length = _generator.Next(1, 100);
|
||||
var length = _generator.Next(1, 100);
|
||||
|
||||
char[] chars = new char[length];
|
||||
var chars = new char[length];
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
int index = _generator.Next(0, AllowedChars.Count - 1);
|
||||
var index = _generator.Next(0, AllowedChars.Count - 1);
|
||||
chars[i] = AllowedChars[index];
|
||||
}
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(chars);
|
||||
var bytes = Encoding.UTF8.GetBytes(chars);
|
||||
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
{
|
||||
var outp = new List<LocalTrack>();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var track = Builder<LocalTrack>
|
||||
.CreateNew()
|
||||
|
@ -281,7 +281,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
public void should_separate_many_albums_in_same_directory()
|
||||
{
|
||||
var tracks = new List<LocalTrack>();
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
tracks.AddRange(GivenTracks($"C:\\music".AsOsAgnostic(), "artist" + i, "album" + i, 10));
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|||
.Build()
|
||||
.ToList();
|
||||
|
||||
for (int i = 0; i < tracks.Count; i++)
|
||||
for (var i = 0; i < tracks.Count; i++)
|
||||
{
|
||||
output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests
|
|||
{
|
||||
GivenArtists();
|
||||
|
||||
string name = "Alice Cooper";
|
||||
var name = "Alice Cooper";
|
||||
AddArtist(name, "ee58c59f-8e7f-4430-b8ca-236c4d3745ae");
|
||||
AddArtist(name, "4d7928cd-7ed2-4282-8c29-c0c9f966f1bd");
|
||||
|
||||
|
|
|
@ -39,13 +39,13 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
[Test]
|
||||
public void should_not_parse_md5()
|
||||
{
|
||||
string hash = "CRAPPY TEST SEED";
|
||||
var hash = "CRAPPY TEST SEED";
|
||||
|
||||
var hashAlgo = System.Security.Cryptography.MD5.Create();
|
||||
|
||||
var repetitions = 100;
|
||||
var success = 0;
|
||||
for (int i = 0; i < repetitions; i++)
|
||||
for (var i = 0; i < repetitions; i++)
|
||||
{
|
||||
var hashData = hashAlgo.ComputeHash(System.Text.Encoding.Default.GetBytes(hash));
|
||||
|
||||
|
@ -64,17 +64,17 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
[TestCase(40)]
|
||||
public void should_not_parse_random(int length)
|
||||
{
|
||||
string charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
var charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
var hashAlgo = new Random();
|
||||
|
||||
var repetitions = 500;
|
||||
var success = 0;
|
||||
for (int i = 0; i < repetitions; i++)
|
||||
for (var i = 0; i < repetitions; i++)
|
||||
{
|
||||
StringBuilder hash = new StringBuilder(length);
|
||||
var hash = new StringBuilder(length);
|
||||
|
||||
for (int x = 0; x < length; x++)
|
||||
for (var x = 0; x < length; x++)
|
||||
{
|
||||
hash.Append(charset[hashAlgo.Next() % charset.Length]);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Profiles.Delay
|
|||
var moving = _last;
|
||||
var result = Subject.Reorder(moving.Id, null).OrderBy(d => d.Order).ToList();
|
||||
|
||||
for (int i = 1; i < result.Count; i++)
|
||||
for (var i = 1; i < result.Count; i++)
|
||||
{
|
||||
var delayProfile = result[i];
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
const string defaultValue = "*";
|
||||
|
||||
string bindAddress = GetValue("BindAddress", defaultValue);
|
||||
var bindAddress = GetValue("BindAddress", defaultValue);
|
||||
if (string.IsNullOrWhiteSpace(bindAddress))
|
||||
{
|
||||
return defaultValue;
|
||||
|
|
|
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Datastore
|
|||
|
||||
using (var conn = _database.OpenConnection())
|
||||
{
|
||||
using (IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
|
||||
using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
|
||||
{
|
||||
foreach (var model in models)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Datastore.Converters
|
|||
}
|
||||
|
||||
string contract;
|
||||
using (JsonDocument body = JsonDocument.Parse(stringValue))
|
||||
using (var body = JsonDocument.Parse(stringValue))
|
||||
{
|
||||
contract = body.RootElement.GetProperty("name").GetString();
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
{
|
||||
while (releaseReader.Read())
|
||||
{
|
||||
int albumId = releaseReader.GetInt32(0);
|
||||
var albumId = releaseReader.GetInt32(0);
|
||||
var albumRelease = Json.Deserialize<LegacyAlbumRelease>(releaseReader.GetString(1));
|
||||
|
||||
AlbumRelease023 toInsert = null;
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
|
||||
private void SetDefaultOptions(IDbConnection conn, IDbTransaction tran)
|
||||
{
|
||||
int metadataId = GetMinProfileId(conn, tran, "MetadataProfiles");
|
||||
int qualityId = GetMinProfileId(conn, tran, "QualityProfiles");
|
||||
var metadataId = GetMinProfileId(conn, tran, "MetadataProfiles");
|
||||
var qualityId = GetMinProfileId(conn, tran, "QualityProfiles");
|
||||
|
||||
if (metadataId == 0 || qualityId == 0)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
|
||||
private void ConvertFileChmodToFolderChmod(IDbConnection conn, IDbTransaction tran)
|
||||
{
|
||||
using (IDbCommand getFileChmodCmd = conn.CreateCommand())
|
||||
using (var getFileChmodCmd = conn.CreateCommand())
|
||||
{
|
||||
getFileChmodCmd.Transaction = tran;
|
||||
getFileChmodCmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'filechmod'";
|
||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
var folderChmodNum = fileChmodNum | ((fileChmodNum & 0x124) >> 2);
|
||||
var folderChmod = Convert.ToString(folderChmodNum, 8).PadLeft(3, '0');
|
||||
|
||||
using (IDbCommand insertCmd = conn.CreateCommand())
|
||||
using (var insertCmd = conn.CreateCommand())
|
||||
{
|
||||
insertCmd.Transaction = tran;
|
||||
insertCmd.CommandText = "INSERT INTO Config (Key, Value) VALUES ('chmodfolder', ?)";
|
||||
|
@ -42,7 +42,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
}
|
||||
}
|
||||
|
||||
using (IDbCommand deleteCmd = conn.CreateCommand())
|
||||
using (var deleteCmd = conn.CreateCommand())
|
||||
{
|
||||
deleteCmd.Transaction = tran;
|
||||
deleteCmd.CommandText = "DELETE FROM Config WHERE Key = 'filechmod'";
|
||||
|
|
|
@ -231,11 +231,11 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
{
|
||||
var updatedNamingConfigs = new List<object>();
|
||||
|
||||
using (IDbCommand namingConfigCmd = conn.CreateCommand())
|
||||
using (var namingConfigCmd = conn.CreateCommand())
|
||||
{
|
||||
namingConfigCmd.Transaction = tran;
|
||||
namingConfigCmd.CommandText = @"SELECT * FROM ""NamingConfig"" LIMIT 1";
|
||||
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
|
||||
using (var namingConfigReader = namingConfigCmd.ExecuteReader())
|
||||
{
|
||||
var standardTrackFormatIndex = namingConfigReader.GetOrdinal("StandardTrackFormat");
|
||||
var multiDiscTrackFormatIndex = namingConfigReader.GetOrdinal("MultiDiscTrackFormat");
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
|
||||
public virtual IList<TableDefinition> ReadDbSchema()
|
||||
{
|
||||
IList<TableDefinition> tables = ReadTables();
|
||||
var tables = ReadTables();
|
||||
foreach (var table in tables)
|
||||
{
|
||||
table.Indexes = ReadIndexes(table.SchemaName, table.Name);
|
||||
|
@ -264,7 +264,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
protected virtual IList<IndexDefinition> ReadIndexes(string schemaName, string tableName)
|
||||
{
|
||||
var sqlCommand = string.Format(@"SELECT type, name, sql FROM sqlite_master WHERE tbl_name = '{0}' AND type = 'index' AND name NOT LIKE 'sqlite_auto%';", tableName);
|
||||
DataTable table = Read(sqlCommand).Tables[0];
|
||||
var table = Read(sqlCommand).Tables[0];
|
||||
|
||||
IList<IndexDefinition> indexes = new List<IndexDefinition>();
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
|
|||
|
||||
private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings)
|
||||
{
|
||||
string url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
||||
var url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
||||
|
||||
var requestBuilder = new JsonRpcRequestBuilder(url);
|
||||
requestBuilder.LogResponseContent = true;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
|
|||
else
|
||||
{
|
||||
_logger.Trace("No directory configured in settings; falling back to client default destination folder.");
|
||||
string defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
||||
var defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
||||
|
||||
if (defaultDestination.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
|
|||
else
|
||||
{
|
||||
_logger.Trace("No directory configured in settings; falling back to client default destination folder.");
|
||||
string defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
||||
var defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
||||
|
||||
if (defaultDestination.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
|||
var items = new List<DownloadClientItem>();
|
||||
|
||||
long totalRemainingSize = 0;
|
||||
long globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading)
|
||||
var globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading)
|
||||
.Select(GetDownloadSpeed)
|
||||
.Sum();
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
|||
|
||||
protected IEnumerable<NzbgetCategory> GetCategories(Dictionary<string, string> config)
|
||||
{
|
||||
for (int i = 1; i < 100; i++)
|
||||
for (var i = 1; i < 100; i++)
|
||||
{
|
||||
var name = config.GetValueOrDefault("Category" + i + ".Name");
|
||||
|
||||
|
|
|
@ -494,7 +494,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
|||
return null;
|
||||
}
|
||||
|
||||
Dictionary<string, QBittorrentLabel> labels = Proxy.GetLabels(Settings);
|
||||
var labels = Proxy.GetLabels(Settings);
|
||||
|
||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && !labels.ContainsKey(Settings.MusicCategory))
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
|
|||
var stringArray = (string[])value;
|
||||
writer.WriteStartArray();
|
||||
|
||||
for (int i = 0; i < stringArray.Length; i++)
|
||||
for (var i = 0; i < stringArray.Length; i++)
|
||||
{
|
||||
writer.WriteValue(stringArray[i]);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
|||
_logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count);
|
||||
|
||||
var items = new List<DownloadClientItem>();
|
||||
foreach (RTorrentTorrent torrent in torrents)
|
||||
foreach (var torrent in torrents)
|
||||
{
|
||||
// Don't concern ourselves with categories other than specified
|
||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && torrent.Category != Settings.MusicCategory)
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
|
|||
{
|
||||
var config = _proxy.GetConfig(Settings);
|
||||
|
||||
OsPath destDir = new OsPath(null);
|
||||
var destDir = new OsPath(null);
|
||||
|
||||
if (config.GetValueOrDefault("dir_active_download_flag") == "true")
|
||||
{
|
||||
|
|
|
@ -32,13 +32,13 @@ namespace NzbDrone.Core.Download.Extensions
|
|||
public static long ElementAsLong(this XElement element, XName name)
|
||||
{
|
||||
var el = element.Element(name);
|
||||
return long.TryParse(el?.Value, out long value) ? value : default;
|
||||
return long.TryParse(el?.Value, out var value) ? value : default;
|
||||
}
|
||||
|
||||
public static int ElementAsInt(this XElement element, XName name)
|
||||
{
|
||||
var el = element.Element(name);
|
||||
return int.TryParse(el?.Value, out int value) ? value : default(int);
|
||||
return int.TryParse(el?.Value, out var value) ? value : default(int);
|
||||
}
|
||||
|
||||
public static int GetIntResponse(this XDocument document)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -105,17 +105,17 @@ namespace NzbDrone.Core
|
|||
}
|
||||
|
||||
var cs = s.ToCharArray();
|
||||
int length = 0;
|
||||
int i = 0;
|
||||
var length = 0;
|
||||
var i = 0;
|
||||
while (i < cs.Length)
|
||||
{
|
||||
int charSize = 1;
|
||||
var charSize = 1;
|
||||
if (i < (cs.Length - 1) && char.IsSurrogate(cs[i]))
|
||||
{
|
||||
charSize = 2;
|
||||
}
|
||||
|
||||
int byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
|
||||
var byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
|
||||
if ((byteSize + length) <= maxLength)
|
||||
{
|
||||
i = i + charSize;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||
}
|
||||
|
||||
var message = _deploymentInfoProvider.PackageGlobalMessage;
|
||||
HealthCheckResult result = HealthCheckResult.Notice;
|
||||
var result = HealthCheckResult.Notice;
|
||||
|
||||
if (message.StartsWith("Error:"))
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace NzbDrone.Core.ImportLists
|
|||
|
||||
var pageableRequestChain = pageableRequestChainSelector(generator);
|
||||
|
||||
for (int i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
for (var i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
{
|
||||
var pageableRequests = pageableRequestChain.GetTier(i);
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
|||
break;
|
||||
}
|
||||
|
||||
return DateTime.TryParseExact(date, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime);
|
||||
return DateTime.TryParseExact(date, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out var result) ? result : default(DateTime);
|
||||
}
|
||||
|
||||
public IList<SpotifyImportListItemInfo> MapSpotifyReleases(IList<SpotifyImportListItemInfo> items)
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
|||
where T : BasicModel
|
||||
where TSettings : SpotifySettingsBase<TSettings>, new()
|
||||
{
|
||||
T result = method(api);
|
||||
var result = method(api);
|
||||
if (result.HasError())
|
||||
{
|
||||
// If unauthorized, refresh token and try again
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace NzbDrone.Core.IndexerSearch
|
|||
|
||||
if (message.ArtistId.HasValue)
|
||||
{
|
||||
int artistId = message.ArtistId.Value;
|
||||
var artistId = message.ArtistId.Value;
|
||||
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Indexers
|
|||
lastReleaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
|
||||
}
|
||||
|
||||
for (int i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
for (var i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
{
|
||||
var pageableRequests = pageableRequestChain.GetTier(i);
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace NzbDrone.Core.Languages
|
|||
return Unknown;
|
||||
}
|
||||
|
||||
Language language = All.FirstOrDefault(v => v.Id == id);
|
||||
var language = All.FirstOrDefault(v => v.Id == id);
|
||||
|
||||
if (language == null)
|
||||
{
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.MediaCover
|
|||
|
||||
private bool EnsureArtistCovers(Artist artist)
|
||||
{
|
||||
bool updated = false;
|
||||
var updated = false;
|
||||
var toResize = new List<Tuple<MediaCover, bool>>();
|
||||
|
||||
foreach (var cover in artist.Metadata.Value.Images)
|
||||
|
@ -196,7 +196,7 @@ namespace NzbDrone.Core.MediaCover
|
|||
|
||||
public bool EnsureAlbumCovers(Album album)
|
||||
{
|
||||
bool updated = false;
|
||||
var updated = false;
|
||||
|
||||
foreach (var cover in album.Images.Where(e => e.CoverType == MediaCoverTypes.Cover))
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ namespace NzbDrone.Core.MediaCover
|
|||
|
||||
private void EnsureResizedCovers(Artist artist, MediaCover cover, bool forceResize, Album album = null)
|
||||
{
|
||||
int[] heights = GetDefaultHeights(cover.CoverType);
|
||||
var heights = GetDefaultHeights(cover.CoverType);
|
||||
|
||||
foreach (var height in heights)
|
||||
{
|
||||
|
|
|
@ -161,13 +161,13 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
OriginalYear = OriginalReleaseDate.HasValue ? (uint)OriginalReleaseDate?.Year : 0;
|
||||
|
||||
foreach (ICodec codec in file.Properties.Codecs)
|
||||
foreach (var codec in file.Properties.Codecs)
|
||||
{
|
||||
IAudioCodec acodec = codec as IAudioCodec;
|
||||
var acodec = codec as IAudioCodec;
|
||||
|
||||
if (acodec != null && (acodec.MediaTypes & MediaTypes.Audio) != MediaTypes.None)
|
||||
{
|
||||
int bitrate = acodec.AudioBitrate;
|
||||
var bitrate = acodec.AudioBitrate;
|
||||
if (bitrate == 0)
|
||||
{
|
||||
// Taglib can't read bitrate for Opus.
|
||||
|
@ -222,7 +222,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
private int EstimateBitrate(TagLib.File file, string path)
|
||||
{
|
||||
int bitrate = 0;
|
||||
var bitrate = 0;
|
||||
try
|
||||
{
|
||||
// Taglib File.Length is unreliable so use System.IO
|
||||
|
@ -241,22 +241,22 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
private DateTime? ReadId3Date(TagLib.Id3v2.Tag tag, string dateTag)
|
||||
{
|
||||
string date = tag.GetTextAsString(dateTag);
|
||||
var date = tag.GetTextAsString(dateTag);
|
||||
|
||||
if (tag.Version == 4)
|
||||
{
|
||||
// the unabused TDRC/TDOR tags
|
||||
return DateTime.TryParse(date, out DateTime result) ? result : default(DateTime?);
|
||||
return DateTime.TryParse(date, out var result) ? result : default(DateTime?);
|
||||
}
|
||||
else if (dateTag == "TDRC")
|
||||
{
|
||||
// taglib maps the v3 TYER and TDAT to TDRC but does it incorrectly
|
||||
return DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime?);
|
||||
return DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result) ? result : default(DateTime?);
|
||||
}
|
||||
else
|
||||
{
|
||||
// taglib maps the v3 TORY to TDRC so we just get a year
|
||||
return int.TryParse(date, out int year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?);
|
||||
return int.TryParse(date, out var year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
var diff = Math.Abs(value - target);
|
||||
if (diff > 0)
|
||||
{
|
||||
for (int i = 0; i < diff; i++)
|
||||
for (var i = 0; i < diff; i++)
|
||||
{
|
||||
Add(key, 1.0);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
private static string Clean(string input)
|
||||
{
|
||||
char[] arr = input.ToLower().RemoveAccent().ToCharArray();
|
||||
var arr = input.ToLower().RemoveAccent().ToCharArray();
|
||||
|
||||
arr = Array.FindAll<char>(arr, c => char.IsLetterOrDigit(c));
|
||||
|
||||
|
@ -171,7 +171,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
public void AddPriority<T>(string key, List<T> values, List<T> options)
|
||||
where T : IEquatable<T>
|
||||
{
|
||||
for (int i = 0; i < options.Count; i++)
|
||||
for (var i = 0; i < options.Count; i++)
|
||||
{
|
||||
if (values.Contains(options[i]))
|
||||
{
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
var releases = GetLocalAlbumReleases(localTracks, config.SingleRelease);
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
foreach (var localRelease in releases)
|
||||
{
|
||||
i++;
|
||||
|
@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
private void IdentifyRelease(LocalAlbumRelease localAlbumRelease, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config)
|
||||
{
|
||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
bool fingerprinted = false;
|
||||
var fingerprinted = false;
|
||||
|
||||
var candidateReleases = _candidateService.GetDbCandidatesFromTags(localAlbumRelease, idOverrides, config.IncludeExisting);
|
||||
|
||||
|
@ -304,7 +304,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
_logger.Debug("Matching {0} track files against {1} candidates", localAlbumRelease.TrackCount, candidateReleases.Count);
|
||||
_logger.Trace("Processing files:\n{0}", string.Join("\n", localAlbumRelease.LocalTracks.Select(x => x.Path)));
|
||||
|
||||
double bestDistance = 1.0;
|
||||
var bestDistance = 1.0;
|
||||
|
||||
foreach (var candidateRelease in candidateReleases)
|
||||
{
|
||||
|
@ -350,10 +350,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
var distances = new Distance[localTracks.Count, mbTracks.Count];
|
||||
var costs = new double[localTracks.Count, mbTracks.Count];
|
||||
|
||||
for (int col = 0; col < mbTracks.Count; col++)
|
||||
for (var col = 0; col < mbTracks.Count; col++)
|
||||
{
|
||||
var totalTrackNumber = DistanceCalculator.GetTotalTrackNumber(mbTracks[col], mbTracks);
|
||||
for (int row = 0; row < localTracks.Count; row++)
|
||||
for (var row = 0; row < localTracks.Count; row++)
|
||||
{
|
||||
distances[row, col] = DistanceCalculator.TrackDistance(localTracks[row], mbTracks[col], totalTrackNumber, false);
|
||||
costs[row, col] = distances[row, col].NormalizedDistance();
|
||||
|
|
|
@ -79,9 +79,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
get
|
||||
{
|
||||
var value = new List<Tuple<int, int>>();
|
||||
for (int row = 0; row < nrow_orig; row++)
|
||||
for (var row = 0; row < nrow_orig; row++)
|
||||
{
|
||||
for (int col = 0; col < ncol_orig; col++)
|
||||
for (var col = 0; col < ncol_orig; col++)
|
||||
{
|
||||
if (M[row, col] == 1)
|
||||
{
|
||||
|
@ -107,9 +107,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
{
|
||||
var newdim = Math.Max(matrix.GetLength(0), matrix.GetLength(1));
|
||||
var outp = new double[newdim, newdim];
|
||||
for (int row = 0; row < matrix.GetLength(0); row++)
|
||||
for (var row = 0; row < matrix.GetLength(0); row++)
|
||||
{
|
||||
for (int col = 0; col < matrix.GetLength(1); col++)
|
||||
for (var col = 0; col < matrix.GetLength(1); col++)
|
||||
{
|
||||
outp[row, col] = matrix[row, col];
|
||||
}
|
||||
|
@ -124,10 +124,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
{
|
||||
double min_in_row;
|
||||
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
min_in_row = C[r, 0];
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (C[r, c] < min_in_row)
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
}
|
||||
}
|
||||
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
C[r, c] -= min_in_row;
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
// matrix. Go to Step 3.
|
||||
private void step_two(ref int step)
|
||||
{
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (C[r, c] == 0 && RowCover[r] == 0 && ColCover[c] == 0)
|
||||
{
|
||||
|
@ -162,12 +162,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
}
|
||||
}
|
||||
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
RowCover[r] = 0;
|
||||
}
|
||||
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
ColCover[c] = 0;
|
||||
}
|
||||
|
@ -181,9 +181,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
private void step_three(ref int step)
|
||||
{
|
||||
int colcount;
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (M[r, c] == 1)
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
}
|
||||
|
||||
colcount = 0;
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (ColCover[c] == 1)
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
// methods to support step 4
|
||||
private void find_a_zero(ref int row, ref int col)
|
||||
{
|
||||
int r = 0;
|
||||
var r = 0;
|
||||
int c;
|
||||
bool done;
|
||||
row = -1;
|
||||
|
@ -249,8 +249,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
private bool star_in_row(int row)
|
||||
{
|
||||
bool tmp = false;
|
||||
for (int c = 0; c < n; c++)
|
||||
var tmp = false;
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (M[row, c] == 1)
|
||||
{
|
||||
|
@ -264,7 +264,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
private void find_star_in_row(int row, ref int col)
|
||||
{
|
||||
col = -1;
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (M[row, c] == 1)
|
||||
{
|
||||
|
@ -280,8 +280,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
// Save the smallest uncovered value and Go to Step 6.
|
||||
private void step_four(ref int step)
|
||||
{
|
||||
int row = -1;
|
||||
int col = -1;
|
||||
var row = -1;
|
||||
var col = -1;
|
||||
bool done;
|
||||
|
||||
done = false;
|
||||
|
@ -317,7 +317,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
private void find_star_in_col(int c, ref int r)
|
||||
{
|
||||
r = -1;
|
||||
for (int i = 0; i < n; i++)
|
||||
for (var i = 0; i < n; i++)
|
||||
{
|
||||
if (M[i, c] == 1)
|
||||
{
|
||||
|
@ -328,7 +328,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
private void find_prime_in_row(int r, ref int c)
|
||||
{
|
||||
for (int j = 0; j < n; j++)
|
||||
for (var j = 0; j < n; j++)
|
||||
{
|
||||
if (M[r, j] == 2)
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
private void augment_path()
|
||||
{
|
||||
for (int p = 0; p < path_count; p++)
|
||||
for (var p = 0; p < path_count; p++)
|
||||
{
|
||||
if (M[path[p, 0], path[p, 1]] == 1)
|
||||
{
|
||||
|
@ -354,12 +354,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
private void clear_covers()
|
||||
{
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
RowCover[r] = 0;
|
||||
}
|
||||
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
ColCover[c] = 0;
|
||||
}
|
||||
|
@ -367,9 +367,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
private void erase_primes()
|
||||
{
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (M[r, c] == 2)
|
||||
{
|
||||
|
@ -389,8 +389,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
private void step_five(ref int step)
|
||||
{
|
||||
bool done;
|
||||
int r = -1;
|
||||
int c = -1;
|
||||
var r = -1;
|
||||
var c = -1;
|
||||
|
||||
path_count = 1;
|
||||
path[path_count - 1, 0] = path_row_0;
|
||||
|
@ -428,9 +428,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
// methods to support step 6
|
||||
private void find_smallest(ref double minval)
|
||||
{
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (RowCover[r] == 0 && ColCover[c] == 0)
|
||||
{
|
||||
|
@ -448,11 +448,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
// altering any stars, primes, or covered lines.
|
||||
private void step_six(ref int step)
|
||||
{
|
||||
double minval = double.MaxValue;
|
||||
var minval = double.MaxValue;
|
||||
find_smallest(ref minval);
|
||||
for (int r = 0; r < n; r++)
|
||||
for (var r = 0; r < n; r++)
|
||||
{
|
||||
for (int c = 0; c < n; c++)
|
||||
for (var c = 0; c < n; c++)
|
||||
{
|
||||
if (RowCover[r] == 1)
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
|||
|
||||
public void Run()
|
||||
{
|
||||
bool done = false;
|
||||
var done = false;
|
||||
while (!done)
|
||||
{
|
||||
switch (step)
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|||
var albumDecisions = decisions.Where(e => e.Item.Album != null && e.Approved)
|
||||
.GroupBy(e => e.Item.Album.ForeignAlbumId).ToList();
|
||||
|
||||
int iDecision = 1;
|
||||
var iDecision = 1;
|
||||
foreach (var albumDecision in albumDecisions)
|
||||
{
|
||||
_logger.ProgressInfo($"Importing album {iDecision++}/{albumDecisions.Count}");
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|||
downloadClientItemInfo = Parser.Parser.ParseAlbumTitle(downloadClientItem.Title);
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
var i = 1;
|
||||
foreach (var file in files)
|
||||
{
|
||||
_logger.ProgressInfo($"Reading file {i++}/{files.Count}");
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
|
|||
|
||||
foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|'))
|
||||
{
|
||||
DirectoryInfo parent = Directory.GetParent(item.Path);
|
||||
var parent = Directory.GetParent(item.Path);
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent.Name.StartsWith(workingFolder))
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
var relDate = album.ReleaseDate.Value;
|
||||
|
||||
// avoiding false +ve checks and set date skewing by not using UTC (Windows)
|
||||
DateTime oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath);
|
||||
var oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath);
|
||||
|
||||
if (OsInfo.IsNotWindows && relDate < EpochTime)
|
||||
{
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||
{
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
for (int i = 0; i < THREAD_LIMIT; i++)
|
||||
for (var i = 0; i < THREAD_LIMIT; i++)
|
||||
{
|
||||
var thread = new Thread(ExecuteCommands);
|
||||
thread.Start();
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||
|
||||
public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified)
|
||||
{
|
||||
dynamic command = GetCommand(commandName);
|
||||
var command = GetCommand(commandName);
|
||||
command.LastExecutionTime = lastExecutionTime;
|
||||
command.LastStartTime = lastStartTime;
|
||||
command.Trigger = trigger;
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.MetadataSource
|
|||
|
||||
public int Compare(Artist x, Artist y)
|
||||
{
|
||||
int result = 0;
|
||||
var result = 0;
|
||||
|
||||
// Prefer exact matches
|
||||
result = Compare(x, y, s => CleanPunctuation(s.Name).Equals(CleanPunctuation(SearchQuery)));
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
{
|
||||
var slug = lowerTitle.Split(':')[1].Trim();
|
||||
|
||||
bool isValid = Guid.TryParse(slug, out var searchGuid);
|
||||
var isValid = Guid.TryParse(slug, out var searchGuid);
|
||||
|
||||
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false)
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
{
|
||||
var slug = lowerTitle.Split(':')[1].Trim();
|
||||
|
||||
bool isValid = Guid.TryParse(slug, out var searchGuid);
|
||||
var isValid = Guid.TryParse(slug, out var searchGuid);
|
||||
|
||||
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false)
|
||||
{
|
||||
|
@ -432,7 +432,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
private static Album MapAlbum(AlbumResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
||||
{
|
||||
Album album = new Album();
|
||||
var album = new Album();
|
||||
album.ForeignAlbumId = resource.Id;
|
||||
album.OldForeignAlbumIds = resource.OldIds;
|
||||
album.Title = resource.Title;
|
||||
|
@ -475,7 +475,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
private static AlbumRelease MapRelease(ReleaseResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
||||
{
|
||||
AlbumRelease release = new AlbumRelease();
|
||||
var release = new AlbumRelease();
|
||||
release.ForeignReleaseId = resource.Id;
|
||||
release.OldForeignReleaseIds = resource.OldIds;
|
||||
release.Title = resource.Title;
|
||||
|
@ -490,7 +490,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
var allTracks = resource.Tracks.Select(x => MapTrack(x, artistDict));
|
||||
if (!allMedia.Any())
|
||||
{
|
||||
foreach (int n in allTracks.Select(x => x.MediumNumber).Distinct())
|
||||
foreach (var n in allTracks.Select(x => x.MediumNumber).Distinct())
|
||||
{
|
||||
allMedia.Add(new Medium { Name = "Unknown", Number = n, Format = "Unknown" });
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
private static Medium MapMedium(MediumResource resource)
|
||||
{
|
||||
Medium medium = new Medium
|
||||
var medium = new Medium
|
||||
{
|
||||
Name = resource.Name,
|
||||
Number = resource.Position,
|
||||
|
@ -526,7 +526,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
private static Track MapTrack(TrackResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
||||
{
|
||||
Track track = new Track
|
||||
var track = new Track
|
||||
{
|
||||
ArtistMetadata = artistDict[resource.ArtistId],
|
||||
Title = resource.TrackName,
|
||||
|
@ -545,7 +545,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
private static ArtistMetadata MapArtistMetadata(ArtistResource resource)
|
||||
{
|
||||
ArtistMetadata artist = new ArtistMetadata();
|
||||
var artist = new ArtistMetadata();
|
||||
|
||||
artist.Name = resource.ArtistName;
|
||||
artist.Aliases = resource.ArtistAliases;
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Music
|
|||
return Album;
|
||||
}
|
||||
|
||||
PrimaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id);
|
||||
var albumType = All.FirstOrDefault(v => v.Id == id);
|
||||
|
||||
if (albumType == null)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Music
|
|||
return Official;
|
||||
}
|
||||
|
||||
ReleaseStatus albumType = All.FirstOrDefault(v => v.Id == id);
|
||||
var albumType = All.FirstOrDefault(v => v.Id == id);
|
||||
|
||||
if (albumType == null)
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Music
|
|||
return Studio;
|
||||
}
|
||||
|
||||
SecondaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id);
|
||||
var albumType = All.FirstOrDefault(v => v.Id == id);
|
||||
|
||||
if (albumType == null)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Music
|
|||
var existingMetadata = FindById(data.Select(x => x.ForeignArtistId).ToList());
|
||||
var updateMetadataList = new List<ArtistMetadata>();
|
||||
var addMetadataList = new List<ArtistMetadata>();
|
||||
int upToDateMetadataCount = 0;
|
||||
var upToDateMetadataCount = 0;
|
||||
|
||||
foreach (var meta in data)
|
||||
{
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace NzbDrone.Core.Music
|
|||
if (_artistService.ArtistPathExists(path))
|
||||
{
|
||||
var basepath = path;
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
do
|
||||
{
|
||||
i++;
|
||||
|
|
|
@ -324,7 +324,7 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
public bool RefreshAlbumInfo(List<Album> albums, List<Album> remoteAlbums, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate)
|
||||
{
|
||||
bool updated = false;
|
||||
var updated = false;
|
||||
|
||||
HashSet<string> updatedMusicbrainzAlbums = null;
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
protected override UpdateResult UpdateEntity(Artist local, Artist remote)
|
||||
{
|
||||
UpdateResult result = UpdateResult.None;
|
||||
var result = UpdateResult.None;
|
||||
|
||||
if (!local.Metadata.Value.Equals(remote.Metadata.Value))
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
private void RefreshSelectedArtists(List<int> artistIds, bool isNew, CommandTrigger trigger)
|
||||
{
|
||||
bool updated = false;
|
||||
var updated = false;
|
||||
var artists = _artistService.GetArtists(artistIds);
|
||||
|
||||
foreach (var artist in artists)
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
public bool RefreshEntityInfo(TEntity local, List<TEntity> remoteList, bool forceChildRefresh, bool forceUpdateFileTags, DateTime? lastUpdate)
|
||||
{
|
||||
bool updated = false;
|
||||
var updated = false;
|
||||
|
||||
LogProgress(local);
|
||||
|
||||
|
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
public bool RefreshEntityInfo(List<TEntity> localList, List<TEntity> remoteList, bool forceChildRefresh, bool forceUpdateFileTags)
|
||||
{
|
||||
bool updated = false;
|
||||
var updated = false;
|
||||
foreach (var entity in localList)
|
||||
{
|
||||
updated |= RefreshEntityInfo(entity, remoteList, forceChildRefresh, forceUpdateFileTags, null);
|
||||
|
|
|
@ -423,7 +423,7 @@ namespace NzbDrone.Core.Organizer
|
|||
{
|
||||
var pattern = string.Empty;
|
||||
|
||||
for (int i = 0; i < tracks.Count; i++)
|
||||
for (var i = 0; i < tracks.Count; i++)
|
||||
{
|
||||
var patternToReplace = i == 0 ? basePattern : formatPattern;
|
||||
|
||||
|
@ -437,7 +437,7 @@ namespace NzbDrone.Core.Organizer
|
|||
{
|
||||
var pattern = string.Empty;
|
||||
|
||||
for (int i = 0; i < tracks.Count; i++)
|
||||
for (var i = 0; i < tracks.Count; i++)
|
||||
{
|
||||
var patternToReplace = i == 0 ? basePattern : formatPattern;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace NzbDrone.Core.Parser
|
|||
path = "fpcalc";
|
||||
|
||||
// check that the command exists
|
||||
Process p = new Process();
|
||||
var p = new Process();
|
||||
p.StartInfo.FileName = path;
|
||||
p.StartInfo.Arguments = "-version";
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Parser
|
|||
p.Start();
|
||||
|
||||
// To avoid deadlocks, always read the output stream first and then wait.
|
||||
string output = p.StandardOutput.ReadToEnd();
|
||||
var output = p.StandardOutput.ReadToEnd();
|
||||
p.WaitForExit(1000);
|
||||
}
|
||||
catch
|
||||
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Parser
|
|||
return null;
|
||||
}
|
||||
|
||||
Process p = new Process();
|
||||
var p = new Process();
|
||||
p.StartInfo.FileName = _fpcalcPath;
|
||||
p.StartInfo.Arguments = $"-version";
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
|
@ -146,7 +146,7 @@ namespace NzbDrone.Core.Parser
|
|||
p.Start();
|
||||
|
||||
// To avoid deadlocks, always read the output stream first and then wait.
|
||||
string output = p.StandardOutput.ReadToEnd();
|
||||
var output = p.StandardOutput.ReadToEnd();
|
||||
p.WaitForExit(1000);
|
||||
|
||||
if (p.ExitCode != 0)
|
||||
|
@ -241,7 +241,7 @@ namespace NzbDrone.Core.Parser
|
|||
{
|
||||
if (IsSetup() && File.Exists(file))
|
||||
{
|
||||
Process p = new Process();
|
||||
var p = new Process();
|
||||
p.StartInfo.FileName = _fpcalcPath;
|
||||
p.StartInfo.Arguments = $"{_fpcalcArgs} \"{file}\"";
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
|
@ -251,14 +251,14 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
_logger.Trace("Executing {0} {1}", p.StartInfo.FileName, p.StartInfo.Arguments);
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
StringBuilder error = new StringBuilder();
|
||||
var output = new StringBuilder();
|
||||
var error = new StringBuilder();
|
||||
|
||||
// see https://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why?lq=1
|
||||
// this is most likely overkill...
|
||||
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
|
||||
using (var outputWaitHandle = new AutoResetEvent(false))
|
||||
{
|
||||
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
|
||||
using (var errorWaitHandle = new AutoResetEvent(false))
|
||||
{
|
||||
DataReceivedEventHandler outputHandler = (sender, e) =>
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ namespace NzbDrone.Core.Parser
|
|||
.Build();
|
||||
|
||||
var sb = new StringBuilder($"client={_acoustIdApiKey}&format=json&meta=recordingids&batch=1", 2000);
|
||||
for (int i = 0; i < toLookup.Count; i++)
|
||||
for (var i = 0; i < toLookup.Count; i++)
|
||||
{
|
||||
sb.Append($"&duration.{i}={toLookup[i].Item2.Duration:F0}&fingerprint.{i}={toLookup[i].Item2.Fingerprint}");
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Parser.Model
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
string albumString = "[Unknown Album]";
|
||||
var albumString = "[Unknown Album]";
|
||||
|
||||
if (AlbumTitle != null)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Parser.Model
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
string trackString = "[Unknown Track]";
|
||||
var trackString = "[Unknown Track]";
|
||||
|
||||
if (TrackNumbers != null && TrackNumbers.Any())
|
||||
{
|
||||
|
|
|
@ -629,9 +629,9 @@ namespace NzbDrone.Core.Parser
|
|||
// TODO: Split into separate method and write unit tests for.
|
||||
var parts = artistName.Split('.');
|
||||
artistName = "";
|
||||
int n = 0;
|
||||
bool previousAcronym = false;
|
||||
string nextPart = "";
|
||||
var n = 0;
|
||||
var previousAcronym = false;
|
||||
var nextPart = "";
|
||||
foreach (var part in parts)
|
||||
{
|
||||
if (parts.Length >= n + 2)
|
||||
|
@ -665,7 +665,7 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
artistName = artistName.Trim(' ');
|
||||
|
||||
ParsedTrackInfo result = new ParsedTrackInfo();
|
||||
var result = new ParsedTrackInfo();
|
||||
|
||||
result.ArtistTitle = artistName;
|
||||
result.ArtistTitleInfo = GetArtistTitleInfo(result.ArtistTitle);
|
||||
|
|
|
@ -635,7 +635,7 @@ namespace NzbDrone.Core.Parser
|
|||
result.Revision.IsRepack = true;
|
||||
}
|
||||
|
||||
Match versionRegexResult = VersionRegex.Match(normalizedName);
|
||||
var versionRegexResult = VersionRegex.Match(normalizedName);
|
||||
|
||||
if (versionRegexResult.Success)
|
||||
{
|
||||
|
@ -643,7 +643,7 @@ namespace NzbDrone.Core.Parser
|
|||
}
|
||||
|
||||
// TODO: re-enable this when we have a reliable way to determine real
|
||||
MatchCollection realRegexResult = RealRegex.Matches(name);
|
||||
var realRegexResult = RealRegex.Matches(name);
|
||||
|
||||
if (realRegexResult.Count > 0)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace NzbDrone.Core.Profiles.Delay
|
|||
|
||||
var all = All().OrderBy(d => d.Order).ToList();
|
||||
|
||||
for (int i = 0; i < all.Count; i++)
|
||||
for (var i = 0; i < all.Count; i++)
|
||||
{
|
||||
if (all[i].Id == 1)
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Profiles.Metadata
|
|||
|
||||
var names = profiles.Select(x => x.Name).ToList();
|
||||
|
||||
int i = 1;
|
||||
var i = 1;
|
||||
emptyProfile.Name = $"{NONE_PROFILE_NAME}.{i}";
|
||||
|
||||
while (names.Contains(emptyProfile.Name))
|
||||
|
|
|
@ -66,8 +66,8 @@ namespace NzbDrone.Core.Qualities
|
|||
|
||||
private void InsertMissingDefinitions()
|
||||
{
|
||||
List<QualityDefinition> insertList = new List<QualityDefinition>();
|
||||
List<QualityDefinition> updateList = new List<QualityDefinition>();
|
||||
var insertList = new List<QualityDefinition>();
|
||||
var updateList = new List<QualityDefinition>();
|
||||
|
||||
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
|
||||
var existingDefinitions = _repo.All().ToList();
|
||||
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Qualities
|
|||
|
||||
public void Execute(ResetQualityDefinitionsCommand message)
|
||||
{
|
||||
List<QualityDefinition> updateList = new List<QualityDefinition>();
|
||||
var updateList = new List<QualityDefinition>();
|
||||
|
||||
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
|
||||
var existingDefinitions = _repo.All().ToList();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue