mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
Merge pull request #6590 from jellyfin/dotnet6
This commit is contained in:
@@ -1150,7 +1150,7 @@ namespace Emby.Server.Implementations.Data
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Enum.TryParse(imageType.ToString(), true, out ImageType type))
|
||||
if (Enum.TryParse(imageType, true, out ImageType type))
|
||||
{
|
||||
image.Type = type;
|
||||
}
|
||||
@@ -1571,7 +1571,6 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
if (reader.TryGetString(index++, out var audioString))
|
||||
{
|
||||
// TODO Span overload coming in the future https://github.com/dotnet/runtime/issues/1916
|
||||
if (Enum.TryParse(audioString, true, out ProgramAudio audio))
|
||||
{
|
||||
item.Audio = audio;
|
||||
@@ -1610,18 +1609,16 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
if (reader.TryGetString(index++, out var lockedFields))
|
||||
{
|
||||
IEnumerable<MetadataField> GetLockedFields(string s)
|
||||
List<MetadataField> fields = null;
|
||||
foreach (var i in lockedFields.AsSpan().Split('|'))
|
||||
{
|
||||
foreach (var i in s.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
||||
{
|
||||
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
||||
{
|
||||
yield return parsedValue;
|
||||
}
|
||||
(fields ??= new List<MetadataField>()).Add(parsedValue);
|
||||
}
|
||||
}
|
||||
|
||||
item.LockedFields = GetLockedFields(lockedFields).ToArray();
|
||||
item.LockedFields = fields?.ToArray() ?? Array.Empty<MetadataField>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,18 +1644,16 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
if (reader.TryGetString(index, out var trailerTypes))
|
||||
{
|
||||
IEnumerable<TrailerType> GetTrailerTypes(string s)
|
||||
List<TrailerType> types = null;
|
||||
foreach (var i in trailerTypes.AsSpan().Split('|'))
|
||||
{
|
||||
foreach (var i in s.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
||||
{
|
||||
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
||||
{
|
||||
yield return parsedValue;
|
||||
}
|
||||
(types ??= new List<TrailerType>()).Add(parsedValue);
|
||||
}
|
||||
}
|
||||
|
||||
trailer.TrailerTypes = GetTrailerTypes(trailerTypes).ToArray();
|
||||
trailer.TrailerTypes = types?.ToArray() ?? Array.Empty<TrailerType>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->
|
||||
|
||||
@@ -1250,10 +1250,8 @@ namespace Emby.Server.Implementations.Library
|
||||
private CollectionTypeOptions? GetCollectionType(string path)
|
||||
{
|
||||
var files = _fileSystem.GetFilePaths(path, new[] { ".collection" }, true, false);
|
||||
foreach (var file in files)
|
||||
foreach (ReadOnlySpan<char> file in files)
|
||||
{
|
||||
// TODO: @bond use a ReadOnlySpan<char> here when Enum.TryParse supports it
|
||||
// https://github.com/dotnet/runtime/issues/20008
|
||||
if (Enum.TryParse<CollectionTypeOptions>(Path.GetFileNameWithoutExtension(file), true, out var res))
|
||||
{
|
||||
return res;
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||
cancellationToken,
|
||||
timeOutSource.Token))
|
||||
{
|
||||
var resTask = udpClient.ReceiveAsync();
|
||||
var resTask = udpClient.ReceiveAsync(linkedSource.Token).AsTask();
|
||||
if (await Task.WhenAny(resTask, Task.Delay(30000, linkedSource.Token)).ConfigureAwait(false) != resTask)
|
||||
{
|
||||
resTask.Dispose();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Emby.Server.Implementations.QuickConnect
|
||||
/// <summary>
|
||||
/// Quick connect implementation.
|
||||
/// </summary>
|
||||
public class QuickConnectManager : IQuickConnect, IDisposable
|
||||
public class QuickConnectManager : IQuickConnect
|
||||
{
|
||||
/// <summary>
|
||||
/// The length of user facing codes.
|
||||
@@ -30,7 +30,6 @@ namespace Emby.Server.Implementations.QuickConnect
|
||||
/// </summary>
|
||||
private const int Timeout = 10;
|
||||
|
||||
private readonly RNGCryptoServiceProvider _rng = new ();
|
||||
private readonly ConcurrentDictionary<string, QuickConnectResult> _currentRequests = new ();
|
||||
private readonly ConcurrentDictionary<string, (DateTime Timestamp, AuthenticationResult AuthenticationResult)> _authorizedSecrets = new ();
|
||||
|
||||
@@ -140,7 +139,7 @@ namespace Emby.Server.Implementations.QuickConnect
|
||||
uint scale = uint.MaxValue;
|
||||
while (scale == uint.MaxValue)
|
||||
{
|
||||
_rng.GetBytes(raw);
|
||||
RandomNumberGenerator.Fill(raw);
|
||||
scale = BitConverter.ToUInt32(raw);
|
||||
}
|
||||
|
||||
@@ -199,31 +198,10 @@ namespace Emby.Server.Implementations.QuickConnect
|
||||
return result.AuthenticationResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose.
|
||||
/// </summary>
|
||||
/// <param name="disposing">Dispose unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_rng.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private string GenerateSecureRandom(int length = 32)
|
||||
{
|
||||
Span<byte> bytes = stackalloc byte[length];
|
||||
_rng.GetBytes(bytes);
|
||||
RandomNumberGenerator.Fill(bytes);
|
||||
|
||||
return Convert.ToHexString(bytes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user