Re: Dashboard-hackers Digest, Vol 28, Issue 30



Tom Lofts skrev:
I have the same problem, so installed and ran the patch - output is below.

Might the problem be something to do with the fact my thunderbird folders are in a none standard location (/media/mine/Tom/Mail/Local Folders)?

Cheers,

Tom
I'm noting a very strange behaviour here and my last patch is yet not giving me enough information to troubleshoot this (man is this frustrating). So... I've created a patch that should print enough information to figure out what's (not) going on.

The problem itself can be traced to somewhere near the IndexFile-method, which is supposed to create an IndexableGenerator that indexes all mails (or what's supposed to be indexed). This leaves us with aprox. three different outcomes:
1. The internals that handle which accounts to index contains a bug
2. The account type associated to a certain file is not supported or not activated (might be parsing errors when reading Thunderbird's preference file)
3. Reported file size of files to index are zero

My guess would be that we land somewhere near number one in the list above. This time though, debugging should be a lot easier. Non-standard file location could be the reason, but there's no reason it should.

Thanks!

Pierre

PS. Joe: It would be very kind of you if you could commit this patch. This patch includes everything from the old patch and some new stuff. Thanks! DS.
--- Util/Thunderbird.cs	22 Aug 2006 19:59:36 -0000	1.3
+++ Util/Thunderbird.cs	3 Sep 2006 17:17:19 -0000
@@ -747,18 +747,19 @@
 
 				try {
 					string key = reg.Match (line).Result ("${key}");
+					Match m = id_reg.Match (key);
 
-					if (key.StartsWith ("account.account")) {
+					if (key.StartsWith ("account.account") && m.Success) {
 						if (Debug)
-							Logger.Log.Debug ("account.account: {0}", id_reg.Match (key).Result ("${id}"));
+							Logger.Log.Debug ("account.account: {0}", m.Result ("${id}"));
 
-						accounts.Enqueue (id_reg.Match (key).Result ("${id}"));
+						accounts.Enqueue (m.Result ("${id}"));
 					}
 
 					tbl [key] = reg.Match (line).Result ("${value}");
 				} catch (Exception e) { 
 					if (Debug)
-						Logger.Log.Debug (e, "ReadAccounts 1:");
+						Logger.Log.Debug (e, "ReadAccounts 1");
 				}
 			}
 			
@@ -783,7 +784,7 @@
 						(string) tbl [id + ".directory"], Convert.ToInt32 ((string) tbl [id + ".port"]), type, delimiter));
 				} catch (Exception e) {
 					if (Debug)
-						Logger.Log.Debug (e, "ReadAccounts 3:");
+						Logger.Log.Debug (e, "ReadAccounts 3: {0}", e);
 					continue;
 				}
 			}

--- beagled/ThunderbirdQueryable/ThunderbirdIndexer.cs	4 Aug 2006 03:24:51 -0000	1.1
+++ beagled/ThunderbirdQueryable/ThunderbirdIndexer.cs	3 Sep 2006 17:17:20 -0000
@@ -106,6 +106,9 @@
 			
 			foreach (string path in root_paths) {
 				foreach (TB.Account account in Thunderbird.ReadAccounts (path)) {
+					if (Thunderbird.Debug)
+						Logger.Log.Debug ("Processing {0} ({1})", account.Server, account.Path);
+					
 					if (Shutdown.ShutdownRequested)
 						return;
 					
@@ -129,6 +132,11 @@
 		public void IndexAccount (TB.Account account)
 		{
 			TB.Account stored_account = GetParentAccount (account.Path);
+			
+			if (Thunderbird.Debug) {
+				Logger.Log.Debug ("Request to index: {0} ({1}) {2}", 
+					account.Server, account.Path, (Directory.Exists (account.Path) ? "Ok" : "Failed"));
+			}
 
 			// We need to act upon changes made to accounts during Thunderbird runtime.
 			// The user might change from plain to SSL, which leads to a new port number
@@ -136,12 +144,21 @@
 			if (stored_account == null && Directory.Exists (account.Path) && supported_types [account.Type] != null) {
 				account_list.Add (account);
 				IndexDirectory (account.Path);
-				//Logger.Log.Info ("Indexing {0} account {1}", account.Type.ToString (), account.Server);
+				
+				if (Thunderbird.Debug)
+					Logger.Log.Debug ("Indexing {0} account {1} ({2})", account.Type.ToString (), account.Server, account.Path);
 			
-			} else if (stored_account == null && File.Exists (account.Path) && supported_types [account.Type] != null) {
-				account_list.Add (account);
-				IndexFile (account.Path);
-				//Logger.Log.Info ("Indexing {0} account {1}", account.Type.ToString (), account.Server);
+			} else if (stored_account == null && File.Exists (account.Path) && supported_types [account.Type] != null) {				
+				try {
+					account_list.Add (account);
+					IndexFile (account.Path);
+				} catch (Exception e) {
+					Logger.Log.Error (e, "Failed to index {0}: {1}", account.Path, e.Message);
+					return;
+				}
+				
+				if (Thunderbird.Debug)
+					Logger.Log.Debug ("Indexing {0} account {1} ({2})", account.Type.ToString (), account.Server, account.Path);
 				
 			} else if (stored_account != null &&
 				(stored_account.Server != account.Server ||
@@ -152,6 +169,9 @@
 				account_list.Remove (stored_account);
 				account_list.Add (account);
 				
+				if (Thunderbird.Debug)
+					Logger.Log.Debug ("Removed: {0}, Added: {1}", stored_account.Path, account.Path);
+				
 				// Make sure all running indexables are aware of this since it can affect the way they index
 				NotificationEventArgs args;
 				args = new NotificationEventArgs (NotificationType.UpdateAccountInformation, stored_account);
@@ -159,6 +179,9 @@
 				OnNotification (args);
 				
 				Logger.Log.Info ("Updated {0} with new account details", account.Server);
+			} else {
+				Logger.Log.Warn ("IndexAccount was called with an invalid account: {0} ({1})", 
+					account.Server, account.Path);
 			}
 		}
 		
@@ -166,8 +189,14 @@
 		{
 			TB.Account account = GetParentAccount (file);
 						
-			if (account == null || supported_types [account.Type] == null || Thunderbird.GetFileSize (file) < 1)
+			if (account == null)
+				throw new Exception (String.Format ("Failed to associate {0} to an account: Account does not exist!", file));
+			else if (supported_types [account.Type] == null)
+				throw new Exception (String.Format ("Account type associated with {0} is not supported!", file));
+			else if (Thunderbird.GetFileSize (file) < 1) {
+				Logger.Log.Info ("Ignoring {0}: it's empty!", file);
 				return;
+			}
 			
 			object[] param = new object[] {this, account, file};
 			ThunderbirdIndexableGenerator generator = Activator.CreateInstance (
@@ -180,6 +209,9 @@
 		{
 			Queue pending = new Queue ();
 			
+			if (Thunderbird.Debug)
+				Logger.Log.Debug ("Recursively indexing {0}", directory);
+			
 			pending.Enqueue (directory);
 			while (pending.Count > 0) {
 				string dir = pending.Dequeue () as string;
@@ -205,7 +237,11 @@
 					if (Shutdown.ShutdownRequested)
 						return;
 					
-					IndexFile (file);
+					try {
+						IndexFile (file);
+					} catch (Exception e) {
+						Logger.Log.Error (e, "Failed to index file {0}: {1}", file, e.Message);
+					}
 				}
 			}
 		}
@@ -220,6 +256,9 @@
 			ScheduleRemoval (Property.NewKeyword ("fixme:account", acc.Server), Scheduler.Priority.Delayed);
 			OnNotification (new NotificationEventArgs (NotificationType.StopIndexing, account));
 			account_list.Remove (acc);
+			
+			if (Thunderbird.Debug)
+				Logger.Log.Debug ("Removed {0} ({1})", acc.Server, acc.Path);
 		}
 
 		private void AddIIndexableTask (IIndexableGenerator generator, string tag)
@@ -358,10 +397,17 @@
 					return;
 
 				// Tell any running indexable about this or start a new one
-				if (queryable.ThisScheduler.ContainsByTag (full_path))
+				if (queryable.ThisScheduler.ContainsByTag (full_path)) {
 					OnNotification (new NotificationEventArgs (NotificationType.RestartIndexing, account));
-				else
+					return;
+				}
+				
+				try {
 					IndexFile (full_path);
+				} catch (Exception e) {
+					Logger.Log.Error (e, "Failed to index {0}: {1}", full_path, e.Message);
+					return;
+				}
 				
 				return;
 			}
@@ -375,10 +421,18 @@
 				
 				// In case we have a running IndexableGenerator, tell it that we have a file that needs to 
 				// be re-indexed.
-				if (queryable.ThisScheduler.ContainsByTag (full_path))
+				if (queryable.ThisScheduler.ContainsByTag (full_path)) {
 					OnNotification (new NotificationEventArgs (NotificationType.RestartIndexing, account));
-				else
+					return;
+				}
+				
+				// If an indexable is not running, launch a new one
+				try {
 					IndexFile (full_path);
+				} catch (Exception e) {
+					Logger.Log.Error (e, "Failed to index {0}: {1}", full_path, e.Message);
+					return;
+				}
 					
 				return;
 			}


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