From f5d0a3352c271718f76e95c75187622ae323716a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Sejkora?= Date: Sun, 15 Sep 2024 20:55:20 +0200 Subject: [PATCH] Manager: Increase delay for likely temporary files --- ArcdpsLogManager/CHANGELOG.md | 3 +++ ArcdpsLogManager/Logs/LogFinder.cs | 6 ++++++ ArcdpsLogManager/ManagerForm.cs | 21 +++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ArcdpsLogManager/CHANGELOG.md b/ArcdpsLogManager/CHANGELOG.md index 1792e028..a988d008 100644 --- a/ArcdpsLogManager/CHANGELOG.md +++ b/ArcdpsLogManager/CHANGELOG.md @@ -4,6 +4,9 @@ This is the full changelog of the arcdps Log Manager. ## Log Manager v1.12.1 (unreleased) +#### Fixes +- Increased delay for detecting files without an extension, should hopefully fix issue with ghost logs appearing. + ## Log Manager v1.12 #### New features diff --git a/ArcdpsLogManager/Logs/LogFinder.cs b/ArcdpsLogManager/Logs/LogFinder.cs index a9cde5a6..063ef44d 100644 --- a/ArcdpsLogManager/Logs/LogFinder.cs +++ b/ArcdpsLogManager/Logs/LogFinder.cs @@ -70,6 +70,12 @@ public bool IsLikelyEvtcLog(string filename) return false; } + /// + /// Arcdps creates a file and then adds into an archive. The file is then deleted. Checks if this is possibly one of these files. + /// It is not guaranteed, however, and this may return true for files that will not be removed. + /// + public bool IsLikelyTemporary(string filename) => !filename.Contains('.'); + public IEnumerable GetTesting() { var player1 = new LogPlayer("Testing player", ":Testing account.1234", 1, Profession.Thief, EliteSpecialization.Daredevil, "01D1DADF-751E-E411-ADEE-AC162DC0070D"); diff --git a/ArcdpsLogManager/ManagerForm.cs b/ArcdpsLogManager/ManagerForm.cs index 9bf24756..605a96c0 100644 --- a/ArcdpsLogManager/ManagerForm.cs +++ b/ArcdpsLogManager/ManagerForm.cs @@ -703,6 +703,7 @@ private void SetupFileSystemWatchers() // We do not want to process logs before they are fully written, // mid-compression and the like, so we add a delay after detecting one. var delay = TimeSpan.FromSeconds(5); + var temporaryFileDelay = TimeSpan.FromSeconds(15); fileSystemWatchers.Clear(); foreach (var directory in Settings.LogRootPaths) @@ -716,7 +717,15 @@ private void SetupFileSystemWatchers() { Task.Run(async () => { - await Task.Delay(delay); + if (LogFinder.IsLikelyTemporary(args.FullPath)) + { + await Task.Delay(temporaryFileDelay); + } + else + { + await Task.Delay(delay); + } + if (File.Exists(args.FullPath) && LogFinder.IsLikelyEvtcLog(args.FullPath)) { Application.Instance.AsyncInvoke(() => AddNewLog(args.FullPath)); @@ -727,7 +736,15 @@ private void SetupFileSystemWatchers() { Task.Run(async () => { - await Task.Delay(delay); + if (LogFinder.IsLikelyTemporary(args.FullPath)) + { + await Task.Delay(temporaryFileDelay); + } + else + { + await Task.Delay(delay); + } + if (File.Exists(args.FullPath) && LogFinder.IsLikelyEvtcLog(args.FullPath)) { Application.Instance.AsyncInvoke(() => AddNewLog(args.FullPath));