]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix a potential crash in the options window for clearing log files if the...
authorsr55 <sr55.hb@outlook.com>
Wed, 29 May 2013 16:56:49 +0000 (16:56 +0000)
committersr55 <sr55.hb@outlook.com>
Wed, 29 May 2013 16:56:49 +0000 (16:56 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5523 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs

index 097663f9cf8dd258b33b3fa811aeee6fa04d36d9..356e12c8cd061ad74594706130c5633a233788c3 100644 (file)
@@ -69,13 +69,20 @@ namespace HandBrake.ApplicationServices.Utilities
                 // Delete old and excessivly large files (> ~50MB).\r
                 foreach (FileInfo file in logFiles)\r
                 {\r
-                    if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep))\r
+                    try\r
                     {\r
-                        File.Delete(file.FullName);\r
+                        if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep))\r
+                        {\r
+                            File.Delete(file.FullName);\r
+                        }\r
+                        else if (file.Length > 50000000)\r
+                        {\r
+                            File.Delete(file.FullName);\r
+                        }\r
                     }\r
-                    else if (file.Length > 50000000)\r
+                    catch (Exception)\r
                     {\r
-                        File.Delete(file.FullName);\r
+                        // Silently ignore files we can't delete. They are probably being used by the app right now.\r
                     }\r
                 }\r
             }\r