diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-08-29 19:12:23 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-08-29 19:12:23 -0500 |
| commit | ea4ca200cd6dda759917dcd76d47d2bddfa5d2f5 (patch) | |
| tree | 4ae493aec8a4cfc0907de66d58dcbc568f2ce31b /src/slskd/Core | |
| parent | 5b063c478b5d5f8e694a5cdea76af0d8eada3150 (diff) | |
| download | slskd-ea4ca200cd6dda759917dcd76d47d2bddfa5d2f5.tar.gz | |
break if the file is being appended to avoid an endless loop
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 |
