mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-13 02:07:12 -07:00
Use async requests for media cover proxy
(cherry picked from commit ad1f185330a30a2a9d27c9d3f18d384e66727c2a) Closes #4126
This commit is contained in:
parent
febf4b26a1
commit
0037a56c2b
5 changed files with 24 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
@ -30,7 +31,7 @@ namespace Lidarr.Http.Frontend.Mappers
|
|||
|
||||
public abstract bool CanHandle(string resourceUrl);
|
||||
|
||||
public IActionResult GetResponse(string resourceUrl)
|
||||
public Task<IActionResult> GetResponse(string resourceUrl)
|
||||
{
|
||||
var filePath = Map(resourceUrl);
|
||||
|
||||
|
@ -41,10 +42,10 @@ namespace Lidarr.Http.Frontend.Mappers
|
|||
contentType = "application/octet-stream";
|
||||
}
|
||||
|
||||
return new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
|
||||
return Task.FromResult<IActionResult>(new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
|
||||
{
|
||||
Encoding = contentType == "text/plain" ? Encoding.UTF8 : null
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
_logger.Warn("File {0} not found", filePath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue