diff options
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/API/Controllers/LogsController.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Core/API/Controllers/LogsController.cs b/src/slskd/Core/API/Controllers/LogsController.cs index 13f8ab95..d7e011eb 100644 --- a/src/slskd/Core/API/Controllers/LogsController.cs +++ b/src/slskd/Core/API/Controllers/LogsController.cs @@ -161,6 +161,8 @@ namespace slskd.Core.API var list = new List<LogRecord>(); + var currentLength = stream.Length; + var reader = new StreamReader(stream); string line; @@ -171,6 +173,15 @@ namespace slskd.Core.API continue; } + if (stream.Position > currentLength) + { + // if we're reading the latest file, Serilog can append it while we're inside of this loop, + // or worse, a problem inside this loop appends lines. if this happens the position will grow + // beyond the length at the start + Log.Information("Parsing of log file {Filename} stopped before end of file; log was appended during the read"); + break; + } + try { // if the line isn't a log, append it to the previous message |
