diff options
Diffstat (limited to 'MediaBrowser.Api/System/SystemService.cs')
| -rw-r--r-- | MediaBrowser.Api/System/SystemService.cs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index a9cec0914..37613c1c8 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api.System /// Class RestartApplication /// </summary> [Route("/System/Restart", "POST", Summary = "Restarts the application, if needed")] - [Authenticated(Roles = "Admin")] + [Authenticated(Roles = "Admin", AllowLocal = true)] public class RestartApplication { } @@ -52,15 +52,14 @@ namespace MediaBrowser.Api.System /// This is currently not authenticated because the uninstaller needs to be able to shutdown the server. /// </summary> [Route("/System/Shutdown", "POST", Summary = "Shuts down the application")] + [Authenticated(Roles = "Admin", AllowLocal = true)] public class ShutdownApplication { - // TODO: This is not currently authenticated due to uninstaller - // Improve later } [Route("/System/Logs", "GET", Summary = "Gets a list of available server log files")] [Authenticated(Roles = "Admin")] - public class GetServerLogs : IReturn<List<LogFile>> + public class GetServerLogs : IReturn<LogFile[]> { } @@ -118,16 +117,15 @@ namespace MediaBrowser.Api.System public object Get(GetServerLogs request) { - List<FileSystemMetadata> files; + IEnumerable<FileSystemMetadata> files; try { - files = _fileSystem.GetFiles(_appPaths.LogDirectoryPath, new[] { ".txt" }, true, false) - .ToList(); + files = _fileSystem.GetFiles(_appPaths.LogDirectoryPath, new[] { ".txt" }, true, false); } catch (IOException) { - files = new List<FileSystemMetadata>(); + files = new FileSystemMetadata[] { }; } var result = files.Select(i => new LogFile @@ -140,7 +138,7 @@ namespace MediaBrowser.Api.System }).OrderByDescending(i => i.DateModified) .ThenByDescending(i => i.DateCreated) .ThenBy(i => i.Name) - .ToList(); + .ToArray(); return ToOptimizedResult(result); } @@ -150,6 +148,12 @@ namespace MediaBrowser.Api.System var file = _fileSystem.GetFiles(_appPaths.LogDirectoryPath) .First(i => string.Equals(i.Name, request.Name, StringComparison.OrdinalIgnoreCase)); + // For older files, assume fully static + if (file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1)) + { + return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShareMode.Read); + } + return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShareMode.ReadWrite); } |
