beagle r4750 - trunk/beagle/Util



Author: dbera
Date: Sat May 10 16:44:17 2008
New Revision: 4750
URL: http://svn.gnome.org/viewvc/beagle?rev=4750&view=rev

Log:
* Util/camel.cs: Throw IOException if camel believes end of file is reached. Later if IOException is caught, then stop further parsing of the summary file. For other exceptions, as before parsing continues for the next header. If end of file is reached (due to currupted file or whatever), then there is no point in trying to parse the summary for next headers.


Modified:
   trunk/beagle/Util/camel.cs

Modified: trunk/beagle/Util/camel.cs
==============================================================================
--- trunk/beagle/Util/camel.cs	(original)
+++ trunk/beagle/Util/camel.cs	Sat May 10 16:44:17 2008
@@ -124,6 +124,15 @@
 				while (info == null && index < header.count) {
 					try {
 						info = s.ReadMessageInfo (f);
+					} catch (IOException) {
+						Log.Warn ("Unexpected end of file. Skipping rest of messages in {0}", s.filename);
+						info = null;
+						index = header.count; // just in case
+						if (f != null) {
+							f.Close ();
+							f = null;
+						}
+						break;
 					} catch (Exception e) {
 						Log.Warn ("Skipping bogus message " +
 							  "[file={0}, index={1}, error={2}]",
@@ -578,7 +587,7 @@
 			}
 
 			if (v == -1)
-				throw new Exception ("Unexpected end of file");
+				throw new IOException ("Unexpected end of file");
 
 			return value | ((byte)(v & 0x7f));
 		}
@@ -606,7 +615,7 @@
 				int v = f.ReadByte ();
 
 				if (v == -1)
-					throw new Exception ("Unexpected end of file");
+					throw new IOException ("Unexpected end of file");
 
 				seconds |= (uint) v << (i * 8);
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]