mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
feat: log download button (#6330)
* feat: add download button to logs view * fix: add using block for `fileStream` if it isnt downloaded
This commit is contained in:
@@ -1275,7 +1275,7 @@ namespace BTCPayServer.Controllers
|
||||
}
|
||||
|
||||
[Route("server/logs/{file?}")]
|
||||
public async Task<IActionResult> LogsView(string? file = null, int offset = 0)
|
||||
public async Task<IActionResult> LogsView(string? file = null, int offset = 0, bool download = false)
|
||||
{
|
||||
if (offset < 0)
|
||||
{
|
||||
@@ -1317,13 +1317,23 @@ namespace BTCPayServer.Controllers
|
||||
return NotFound();
|
||||
try
|
||||
{
|
||||
using var fileStream = new FileStream(
|
||||
var fileStream = new FileStream(
|
||||
fi.FullName,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.ReadWrite);
|
||||
using var reader = new StreamReader(fileStream);
|
||||
vm.Log = await reader.ReadToEndAsync();
|
||||
if (download)
|
||||
{
|
||||
return new FileStreamResult(fileStream, "text/plain")
|
||||
{
|
||||
FileDownloadName = file
|
||||
};
|
||||
}
|
||||
await using (fileStream)
|
||||
{
|
||||
using var reader = new StreamReader(fileStream);
|
||||
vm.Log = await reader.ReadToEndAsync();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user