From bc1dadefaa3724a2fd3f88080bbcda9adc336877 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 13 Jun 2017 18:21:12 +0100 Subject: [PATCH] Do not exception on thread abort. --- osrepodbmgr.Core/ChangeLog | 10 ++++++++ osrepodbmgr.Core/Workers/Clamd.cs | 5 ++++ osrepodbmgr.Core/Workers/Compression.cs | 25 ++++++++++++++++++ osrepodbmgr.Core/Workers/Database.cs | 31 +++++++++++++++++++++++ osrepodbmgr.Core/Workers/DiscImageChef.cs | 6 +++++ osrepodbmgr.Core/Workers/Files.cs | 28 +++++++++++++++++++- osrepodbmgr.Core/Workers/VirusTotal.cs | 3 +++ 7 files changed, 107 insertions(+), 1 deletion(-) diff --git a/osrepodbmgr.Core/ChangeLog b/osrepodbmgr.Core/ChangeLog index 0b283bb..f04e6a1 100644 --- a/osrepodbmgr.Core/ChangeLog +++ b/osrepodbmgr.Core/ChangeLog @@ -1,3 +1,13 @@ +2017-06-13 Natalia Portillo + + * Workers/Clamd.cs: + * Workers/Files.cs: + * Workers/Database.cs: + * Workers/VirusTotal.cs: + * Workers/Compression.cs: + * Workers/DiscImageChef.cs: + Do not exception on thread abort. + 2017-06-06 Natalia Portillo * AlgoEnum.cs: diff --git a/osrepodbmgr.Core/Workers/Clamd.cs b/osrepodbmgr.Core/Workers/Clamd.cs index 70d3ee1..fa38fed 100644 --- a/osrepodbmgr.Core/Workers/Clamd.cs +++ b/osrepodbmgr.Core/Workers/Clamd.cs @@ -270,10 +270,15 @@ namespace osrepodbmgr.Core return; } + catch(System.Threading.ThreadAbortException) + { } catch(Exception ex) { if(Failed != null) Failed(string.Format("Exception {0} when calling clamd", ex.Message)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } diff --git a/osrepodbmgr.Core/Workers/Compression.cs b/osrepodbmgr.Core/Workers/Compression.cs index 37fac72..c7824a9 100644 --- a/osrepodbmgr.Core/Workers/Compression.cs +++ b/osrepodbmgr.Core/Workers/Compression.cs @@ -299,12 +299,17 @@ namespace osrepodbmgr.Core if(FinishedWithText != null) FinishedWithText(string.Format("Correctly added operating system with MDID {0}", mdid)); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -433,12 +438,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -471,6 +481,8 @@ namespace osrepodbmgr.Core Context.tmpFolder = tmpFolder; } + catch(ThreadAbortException) + { } catch(Exception) { if(Debugger.IsAttached) @@ -507,6 +519,9 @@ namespace osrepodbmgr.Core throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } else @@ -548,12 +563,17 @@ namespace osrepodbmgr.Core Finished(); } } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -692,12 +712,17 @@ namespace osrepodbmgr.Core zipCurrentEntryName = ""; zf.Save(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } diff --git a/osrepodbmgr.Core/Workers/Database.cs b/osrepodbmgr.Core/Workers/Database.cs index 5140f3c..a509fbc 100644 --- a/osrepodbmgr.Core/Workers/Database.cs +++ b/osrepodbmgr.Core/Workers/Database.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Threading; namespace osrepodbmgr.Core { @@ -77,12 +78,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -176,12 +182,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -261,12 +272,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -315,12 +331,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -380,12 +401,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -398,12 +424,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } diff --git a/osrepodbmgr.Core/Workers/DiscImageChef.cs b/osrepodbmgr.Core/Workers/DiscImageChef.cs index bfec184..f193e79 100644 --- a/osrepodbmgr.Core/Workers/DiscImageChef.cs +++ b/osrepodbmgr.Core/Workers/DiscImageChef.cs @@ -123,6 +123,9 @@ namespace osrepodbmgr.Core if(Failed != null) Failed(string.Format("Unable to open image format\n" + "Error: {0}", ex.Message)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif return; } @@ -989,6 +992,9 @@ namespace osrepodbmgr.Core { if(Failed != null) Failed(string.Format("Error reading file: {0}\n{1}", ex.Message, ex.StackTrace)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } diff --git a/osrepodbmgr.Core/Workers/Files.cs b/osrepodbmgr.Core/Workers/Files.cs index 8de0d9a..d44fdbe 100644 --- a/osrepodbmgr.Core/Workers/Files.cs +++ b/osrepodbmgr.Core/Workers/Files.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Threading; using System.Xml; using System.Xml.Serialization; using DiscImageChef.Checksums; @@ -85,12 +86,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -491,12 +497,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -511,7 +522,9 @@ namespace osrepodbmgr.Core Finished(); } } - catch(System.IO.IOException) + catch(ThreadAbortException) + { } + catch(IOException) { // Could not delete temporary files, do not crash. if(Finished != null) @@ -523,6 +536,9 @@ namespace osrepodbmgr.Core throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -585,12 +601,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } @@ -789,12 +810,17 @@ namespace osrepodbmgr.Core if(Finished != null) Finished(); } + catch(ThreadAbortException) + { } catch(Exception ex) { if(Debugger.IsAttached) throw; if(Failed != null) Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } diff --git a/osrepodbmgr.Core/Workers/VirusTotal.cs b/osrepodbmgr.Core/Workers/VirusTotal.cs index e6d6398..7027e12 100644 --- a/osrepodbmgr.Core/Workers/VirusTotal.cs +++ b/osrepodbmgr.Core/Workers/VirusTotal.cs @@ -389,6 +389,9 @@ namespace osrepodbmgr.Core { if(Failed != null) Failed(string.Format("Exception {0} when calling VirusTotal", ex.InnerException.Message)); +#if DEBUG + Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); +#endif } } }