mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-17 15:46:22 +00:00
Lower the amount of running tasks
This commit is contained in:
@@ -86,8 +86,7 @@ namespace Emby.Server.Implementations.SocketSharp
|
||||
else
|
||||
{
|
||||
// We use a substream, as in 2.x we will support large uploads streamed to disk,
|
||||
var sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length);
|
||||
files[e.Name] = sub;
|
||||
files[e.Name] = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,7 +373,7 @@ namespace Emby.Server.Implementations.SocketSharp
|
||||
|
||||
var elem = new Element();
|
||||
ReadOnlySpan<char> header;
|
||||
while ((header = ReadHeaders().AsSpan()) != null)
|
||||
while ((header = ReadLine().AsSpan()).Length != 0)
|
||||
{
|
||||
if (header.StartsWith("Content-Disposition:".AsSpan(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -513,17 +512,6 @@ namespace Emby.Server.Implementations.SocketSharp
|
||||
return false;
|
||||
}
|
||||
|
||||
private string ReadHeaders()
|
||||
{
|
||||
string s = ReadLine();
|
||||
if (s.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private static bool CompareBytes(byte[] orig, byte[] other)
|
||||
{
|
||||
for (int i = orig.Length - 1; i >= 0; i--)
|
||||
|
||||
@@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -474,27 +474,28 @@ namespace Emby.Server.Implementations.SocketSharp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (httpFiles == null)
|
||||
if (httpFiles != null)
|
||||
{
|
||||
if (files == null)
|
||||
{
|
||||
return httpFiles = Array.Empty<IHttpFile>();
|
||||
}
|
||||
return httpFiles;
|
||||
}
|
||||
|
||||
httpFiles = new IHttpFile[files.Count];
|
||||
var i = 0;
|
||||
foreach (var pair in files)
|
||||
if (files == null)
|
||||
{
|
||||
return httpFiles = Array.Empty<IHttpFile>();
|
||||
}
|
||||
|
||||
var values = files.Values;
|
||||
httpFiles = new IHttpFile[values.Count];
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
{
|
||||
var reqFile = values.ElementAt(i);
|
||||
httpFiles[i] = new HttpFile
|
||||
{
|
||||
var reqFile = pair.Value;
|
||||
httpFiles[i] = new HttpFile
|
||||
{
|
||||
ContentType = reqFile.ContentType,
|
||||
ContentLength = reqFile.ContentLength,
|
||||
FileName = reqFile.FileName,
|
||||
InputStream = reqFile.InputStream,
|
||||
};
|
||||
i++;
|
||||
}
|
||||
ContentType = reqFile.ContentType,
|
||||
ContentLength = reqFile.ContentLength,
|
||||
FileName = reqFile.FileName,
|
||||
InputStream = reqFile.InputStream,
|
||||
};
|
||||
}
|
||||
|
||||
return httpFiles;
|
||||
|
||||
Reference in New Issue
Block a user