|
|
@ -1,9 +1,7 @@
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Ombi.Attributes;
|
|
|
|
using Ombi.Attributes;
|
|
|
@ -13,9 +11,9 @@ namespace Ombi.Controllers.V2
|
|
|
|
[Admin]
|
|
|
|
[Admin]
|
|
|
|
public class SystemController : V2Controller
|
|
|
|
public class SystemController : V2Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IHostingEnvironment _hosting;
|
|
|
|
private readonly IWebHostEnvironment _hosting;
|
|
|
|
|
|
|
|
|
|
|
|
public SystemController(IHostingEnvironment hosting)
|
|
|
|
public SystemController(IWebHostEnvironment hosting)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_hosting = hosting;
|
|
|
|
_hosting = hosting;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -35,22 +33,18 @@ namespace Ombi.Controllers.V2
|
|
|
|
public async Task<IActionResult> ReadLogFile(string logFileName, CancellationToken token)
|
|
|
|
public async Task<IActionResult> ReadLogFile(string logFileName, CancellationToken token)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var logFile = Path.Combine(_hosting.ContentRootPath, "Logs", logFileName);
|
|
|
|
var logFile = Path.Combine(_hosting.ContentRootPath, "Logs", logFileName);
|
|
|
|
using (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
|
|
|
await using var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
|
|
using (StreamReader reader = new StreamReader(fs))
|
|
|
|
using StreamReader reader = new StreamReader(fs);
|
|
|
|
{
|
|
|
|
return Ok(await reader.ReadToEndAsync());
|
|
|
|
return Ok(await reader.ReadToEndAsync());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("logs/download/{logFileName}")]
|
|
|
|
[HttpGet("logs/download/{logFileName}")]
|
|
|
|
public IActionResult Download(string logFileName, CancellationToken token)
|
|
|
|
public IActionResult Download(string logFileName, CancellationToken token)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var logFile = Path.Combine(_hosting.ContentRootPath, "Logs", logFileName);
|
|
|
|
var logFile = Path.Combine(_hosting.ContentRootPath, "Logs", logFileName);
|
|
|
|
using (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
|
|
|
using var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
|
|
using (StreamReader reader = new StreamReader(fs))
|
|
|
|
using StreamReader reader = new StreamReader(fs);
|
|
|
|
{
|
|
|
|
return File(reader.BaseStream, "application/octet-stream", logFileName);
|
|
|
|
return File(reader.BaseStream, "application/octet-stream", logFileName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|