[beagle] Add a config option to store snippets for email attachments. Attachments can often be huge, so there



commit e3ef982d5643ed0d9cc4820e943cff84f63cf308
Author: D Bera <dbera web gmail com>
Date:   Mon Aug 17 00:22:25 2009 -0400

    Add a config option to store snippets for email attachments. Attachments can often be huge, so there is a separate config option to turn this on.

 beagle/Filters/FilterMail.cs             |   10 ++++++++--
 beagle/Util/Config.cs                    |    1 +
 beagle/conf-data/config-files/Daemon.xml |    1 +
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/beagle/Filters/FilterMail.cs b/beagle/Filters/FilterMail.cs
index 197b6d7..7c807e7 100644
--- a/beagle/Filters/FilterMail.cs
+++ b/beagle/Filters/FilterMail.cs
@@ -42,6 +42,7 @@ namespace Beagle.Filters {
 
 		private static bool gmime_initialized = false;
 		private static bool gmime_broken = false;
+		private static bool snippet_attachment = false;
 
 		private GMime.Message message;
 		private PartHandler handler;
@@ -55,7 +56,9 @@ namespace Beagle.Filters {
 			// 3: Add standard file properties to attachments.
 			// 4: Store snippets
 			// 5: Store mailing list id as tokenized
-			SetVersion (5);
+			// 6: Store snippets for attachments - this is controlled separately
+			//    since attachments can often be huge and take up a lot of space.
+			SetVersion (6);
 
 			SnippetMode = true;
 			SetFileType ("mail");
@@ -81,6 +84,8 @@ namespace Beagle.Filters {
 							  1 /* Should be more than priority of text filter */);
 				AddSupportedFlavor (flavor);
 			}
+
+			snippet_attachment = Conf.Daemon.GetOption(Conf.Names.EnableEmailAttachmentSnippet, false);
 		}
 
 		protected override void DoOpen (FileInfo info)
@@ -454,7 +459,8 @@ namespace Beagle.Filters {
 							child.MimeType = mime_type;
 
 							// If this is the richest part we found for multipart emails, add its content to textcache
-							if (this.depth == 1 && this.count == 0)
+							if (snippet_attachment ||
+							    (this.depth == 1 && this.count == 0))
 								child.CacheContent = true;
 							else
 								child.CacheContent = false;
diff --git a/beagle/Util/Config.cs b/beagle/Util/Config.cs
index 5e4372b..05d7c11 100644
--- a/beagle/Util/Config.cs
+++ b/beagle/Util/Config.cs
@@ -119,6 +119,7 @@ namespace Beagle.Util {
 			public const string AllowRoot = "AllowRoot"; // default false
 			public const string IndexOnBattery = "IndexOnBattery"; // default false
 			public const string IndexFasterOnScreensaver = "IndexFasterOnScreensaver"; // default true
+			public const string EnableEmailAttachmentSnippet = "EnableEmailAttachmentSnippet"; // default false
 			// list (1 param)
 			public const string StaticQueryables = "StaticQueryables";
 			public const string DeniedBackends = "DeniedBackends";
diff --git a/beagle/conf-data/config-files/Daemon.xml b/beagle/conf-data/config-files/Daemon.xml
index 1dd1f52..217fe3f 100644
--- a/beagle/conf-data/config-files/Daemon.xml
+++ b/beagle/conf-data/config-files/Daemon.xml
@@ -28,4 +28,5 @@
 	<Value>drafts</Value>
 	<Value>templates</Value>
     </ListOption>
+    <BoolOption Name="EnableEmailAttachmentSnippet" Description="Enable snippet for email attachments. This may significantly increase amount of disk space used">false</BoolOption>
 </BeagleConf>



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