From e0c83de39ee1c7533842c566b4cbea80c0257f99 Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 29 May 2013 16:56:49 +0000 Subject: [PATCH] WinGui: Fix a potential crash in the options window for clearing log files if the logs are currently in use. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5523 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Utilities/GeneralUtilities.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index 097663f9c..356e12c8c 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -69,13 +69,20 @@ namespace HandBrake.ApplicationServices.Utilities // Delete old and excessivly large files (> ~50MB). foreach (FileInfo file in logFiles) { - if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep)) + try { - File.Delete(file.FullName); + if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep)) + { + File.Delete(file.FullName); + } + else if (file.Length > 50000000) + { + File.Delete(file.FullName); + } } - else if (file.Length > 50000000) + catch (Exception) { - File.Delete(file.FullName); + // Silently ignore files we can't delete. They are probably being used by the app right now. } } } -- 2.40.0