A few small Beagle bits
- From: Michael Bayne <mdb samskivert com>
- To: dashboard-hackers gnome org
- Subject: A few small Beagle bits
- Date: Mon, 4 Oct 2004 01:37:56 -0700 (PDT)
Ahoy mates,
I fixed a small bug in ImLog where it was failing to close a StreamReader
(this caused it to freak out when parsing old-style GAIM logs where it
creates multiple GaimLog instances for the same file, but the first one
leaves its StreamReader open, preventing all subsequent instances from
opening and reading the file).
Additionally, I modified camel.cs to improve robustness when parsing
messages. My evolution summaries must be borked, but that's no reason for
the parser to choke (it was casting very large numbers from unsigned to
signed integers and then freaking out when the value was less than zero).
It also now copes gracefully if an exception is thrown when parsing the
message summaries.
I haven't looked into it more closely, but queries from the GAIM log take
an unexpectedly long time to return (10 to 15 seconds), but I only have
about 6 megs of conversation logs (the index files are about 1.3 megs).
That seems unlikely to be enough data to strain Lucene.
While I'm yapping, does anyone know if there exists something like the
Java Mail library for C#/Mono? I'd like to write a Queryable that talks
directly to an IMAP server as I don't happen to use Evolution.
-- mdb samskivert com
Index: Util/ImLog.cs
===================================================================
RCS file: /cvs/gnome/beagle/Util/ImLog.cs,v
retrieving revision 1.7
diff -u -p -r1.7 ImLog.cs
--- Util/ImLog.cs 22 Sep 2004 08:41:36 -0000 1.7
+++ Util/ImLog.cs 4 Oct 2004 08:00:25 -0000
@@ -343,6 +343,8 @@ namespace Beagle.Util {
offset = newOffset;
}
+
+ sr.Close();
}
public static ICollection ScanLog (FileInfo file)
Index: Util/camel.cs
===================================================================
RCS file: /cvs/gnome/beagle/Util/camel.cs,v
retrieving revision 1.5
diff -u -p -r1.5 camel.cs
--- Util/camel.cs 1 Jun 2004 02:25:26 -0000 1.5
+++ Util/camel.cs 4 Oct 2004 08:15:57 -0000
@@ -9,6 +9,7 @@
using System.IO;
using System;
+using System.Collections;
using System.Globalization;
using System.Text;
@@ -64,11 +65,19 @@ public class Summary {
using (FileStream f = File.OpenRead (file)){
header = new ImapSummaryHeader (f);
- messages = new MessageInfo [header.count];
-
+ ArrayList msgs = new ArrayList ();
for (int i = 0; i < header.count; i++){
- messages [i] = new ImapMessageInfo (f);
+ try {
+ msgs.Add(new ImapMessageInfo (f));
+ } catch (Exception e) {
+ Logger.Log.Warn ("Skipping bogus message " +
+ "[file={0}, index={1}, error={2}]",
+ file, i, e.ToString());
+ }
}
+
+ messages = new MessageInfo [msgs.Count];
+ msgs.CopyTo (messages);
}
}
}
@@ -343,7 +352,7 @@ public class Summary {
// Ok, this is a token from the list, we can ignore it
return "token_from_list";
- } else if (len > 10240) {
+ } else if (len < 0 || len > 10240) {
throw new Exception ();
} else {
len -= 32;
@@ -358,7 +367,7 @@ public class Summary {
int len = (int) UInt (f);
len--;
- if (len > 65535)
+ if (len < 0 || len > 65535)
throw new Exception ();
byte [] buffer = new byte [len];
f.Read (buffer, 0, (int) len);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]