PATCH: make gaim backend indexer more robust
- From: Jamin Philip Gray <jamin pubcrawler org>
- To: dashboard-hackers <dashboard-hackers gnome org>
- Cc: Nat Friedman <nat nat org>
- Subject: PATCH: make gaim backend indexer more robust
- Date: Tue, 22 Jul 2003 11:59:40 -0500 (CDT)
I had some trouble getting the gaim backend to index my conversation logs. It kept
getting array index out of bounds exceptions on certain files. So I made a change
to make it more robust by skipping any file that causes an exception to be thrown.
The patch is attached.
--
name: Jamin Philip Gray
email: jamin pubcrawler org
icq: 1361499
aim: jamingray47
yahoo: jamin47
web: http://pubcrawler.org
"Got to kick at the darkness 'till it bleeds daylight"
--Bruce Cockburn from "Lovers In A Dangerous Time"
Index: backends/backend-gaimlog.cs
===================================================================
RCS file: /cvs/gnome/dashboard/backends/backend-gaimlog.cs,v
retrieving revision 1.15
diff -u -r1.15 backend-gaimlog.cs
--- backends/backend-gaimlog.cs 21 Jul 2003 14:19:41 -0000 1.15
+++ backends/backend-gaimlog.cs 22 Jul 2003 16:54:57 -0000
@@ -411,17 +411,27 @@
string [] buddys;
try {
+ Console.WriteLine ("Trying to read {0}*.log", path);
buddys = Directory.GetFiles (path, "*.log");
- } catch {
+ } catch (Exception e) {
Console.WriteLine ("GaimLog backend: No gaim logs available");
+ Console.WriteLine ("Error: {0}", e.ToString());
return Buddys; // empty
}
foreach (string buddy in buddys) {
- string buddy_name = buddy.Substring (path.Length, buddy.Length - path.Length);
- buddy_name = buddy_name.Substring (0, buddy_name.LastIndexOf ('.'));
- buddy_name.Substring (0, buddy_name.Length - 4);
- Buddys.Add (buddy_name);
+ try
+ {
+ string buddy_name = buddy.Substring (path.Length, buddy.Length - path.Length);
+ buddy_name = buddy_name.Substring (0, buddy_name.LastIndexOf ('.'));
+ buddy_name.Substring (0, buddy_name.Length - 4);
+ Buddys.Add (buddy_name);
+ }
+ catch
+ {
+ // Skip the filename that failed
+ continue;
+ }
}
return Buddys;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]