From c2f47cf736f0aee0bc712dcd30affdc60b41c49f Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Fri, 27 Oct 2023 19:16:06 +0200
Subject: [PATCH] Skip existing lines when a log file is recreated due to
 spurious file creation events

---
 src/logs/log_file_watcher.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/logs/log_file_watcher.rs b/src/logs/log_file_watcher.rs
index 5e3439f..42e291c 100644
--- a/src/logs/log_file_watcher.rs
+++ b/src/logs/log_file_watcher.rs
@@ -161,6 +161,11 @@ impl LogWatcher {
 							}
 						};
 						
+						while let Ok(Some(_)) = self.state.lines.next_line().await {
+							// There are occasional spurious file creation events, so reading
+							// from the beginning would read lines that were already counted.
+						}
+						
 						continue 'read_loop;
 					}
 				}