Sync static resource controller with upstream

(cherry picked from commit ad1f185330a30a2a9d27c9d3f18d384e66727c2a)
This commit is contained in:
Bogdan
2023-09-16 15:07:39 +03:00
parent 3ed6ef0336
commit 840f2ae3e6
3 changed files with 15 additions and 12 deletions

View File

@@ -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 Prowlarr.Http.Frontend.Mappers
public abstract bool CanHandle(string resourceUrl);
public FileStreamResult GetResponse(string resourceUrl)
public Task<FileStreamResult> GetResponse(string resourceUrl)
{
var filePath = Map(resourceUrl);
@@ -41,10 +42,10 @@ namespace Prowlarr.Http.Frontend.Mappers
contentType = "application/octet-stream";
}
return new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
return Task.FromResult(new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
{
Encoding = contentType == "text/plain" ? Encoding.UTF8 : null
});
}));
}
_logger.Warn("File {0} not found", filePath);