From 7fe11b8094ca623856ceefaf162ecc6525cc3dc2 Mon Sep 17 00:00:00 2001 From: Xjph Date: Fri, 8 Apr 2022 15:51:43 -0230 Subject: [PATCH] fix monitor crash on no journals --- ObservatoryCore/LogMonitor.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ObservatoryCore/LogMonitor.cs b/ObservatoryCore/LogMonitor.cs index 1f18a1e..44ad93f 100644 --- a/ObservatoryCore/LogMonitor.cs +++ b/ObservatoryCore/LogMonitor.cs @@ -423,10 +423,15 @@ namespace Observatory { while (IsMonitoring()) { - FileInfo fileToPoke = GetJournalFilesOrdered(journalFolder).Last(); + var journals = GetJournalFilesOrdered(journalFolder); - using FileStream stream = fileToPoke.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - stream.Close(); + if (journals.Any()) + { + FileInfo fileToPoke = GetJournalFilesOrdered(journalFolder).Last(); + + using FileStream stream = fileToPoke.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + stream.Close(); + } System.Threading.Thread.Sleep(250); } });