summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-05-29 16:56:49 +0000
committersr55 <[email protected]>2013-05-29 16:56:49 +0000
commite0c83de39ee1c7533842c566b4cbea80c0257f99 (patch)
tree8dbda8b3c7bc840c4af52f9aefeb354b4d286d2c
parentbbcd6ff1ec36b81935c1a059a19580a1c1bee98d (diff)
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
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs15
1 files 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.
}
}
}