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