diff --git a/CHANGELOG.md b/CHANGELOG.md index eba22bff..fb77ba71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed +- Rewrite log page to read directly from log files instead of sqlite ## [0.7.1-beta] - 2023-01-03 ### Added diff --git a/ErsatzTV.Application/Logs/Queries/GetRecentLogEntriesHandler.cs b/ErsatzTV.Application/Logs/Queries/GetRecentLogEntriesHandler.cs index 885409b9..ca6aac47 100644 --- a/ErsatzTV.Application/Logs/Queries/GetRecentLogEntriesHandler.cs +++ b/ErsatzTV.Application/Logs/Queries/GetRecentLogEntriesHandler.cs @@ -56,7 +56,8 @@ public class GetRecentLogEntriesHandler : IRequestHandler ReadFrom(string file) { - using StreamReader reader = File.OpenText(file); + using FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using var reader = new StreamReader(fs); while (reader.ReadLine() is { } line) { yield return line; diff --git a/ErsatzTV/Pages/TraktLists.razor b/ErsatzTV/Pages/TraktLists.razor index a84dfa79..1291d0b5 100644 --- a/ErsatzTV/Pages/TraktLists.razor +++ b/ErsatzTV/Pages/TraktLists.razor @@ -130,10 +130,21 @@ private async Task> ServerReloadTraktLists(TableState state) { - await _mediator.Send(new SaveConfigElementByKey(ConfigElementKey.TraktListsPageSize, state.PageSize.ToString()), _cts.Token); + try + { + await _mediator.Send(new SaveConfigElementByKey(ConfigElementKey.TraktListsPageSize, state.PageSize.ToString()), _cts.Token); - PagedTraktListsViewModel data = await _mediator.Send(new GetPagedTraktLists(state.Page, state.PageSize), _cts.Token); - return new TableData { TotalItems = data.TotalCount, Items = data.Page }; + PagedTraktListsViewModel data = await _mediator.Send(new GetPagedTraktLists(state.Page, state.PageSize), _cts.Token); + return new TableData { TotalItems = data.TotalCount, Items = data.Page }; + } + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) + { + return new TableData + { + TotalItems = 0, + Items = Array.Empty() + }; + } } private async Task AddTraktList()