Finally! Patch to Query extended properties
- From: "Daniel Labella de la Cruz" <dani labella gmail com>
- To: dashboard-hackers gnome org, joe joeshaw org
- Subject: Finally! Patch to Query extended properties
- Date: Wed, 25 Jul 2007 10:59:40 +0200
Hi!
This is my litte contribution to beagle, I hope that it can help us in somethig...
Sorry if the diff's are wrong maked (please be gentle is my first time...jejeje)
If someone want test it or something is worng,please send me a feedback... thank you!
Thank you Joe for your support!!!!
--- ./beagle-0.2.17-orig/beagled/FileAttributes.cs 2007-02-07 20:04:14.000000000 +0100
+++ ./beagle-0.2.17/beagled/FileAttributes.cs 2007-07-06 08:48:47.000000000
+0200
@@ -42,6 +42,9 @@
private string filter_name;
private int filter_version;
+ private int xproperty_count;
+
+
public Guid UniqueId {
get { return unique_id; }
set { unique_id = value; }
@@ -90,6 +93,11 @@
get { return filter_version; }
set { filter_version = value; }
}
+
+ public int XPropertyCount {
+ get { return xproperty_count; }
+ set { xproperty_count = value; }
+ }
}
}
--- ./beagle-0.2.17-orig/beagled/FileSystemQueryable/FileSystemQueryable.cs 2007-02-13 20:09:
26.000000000 +0100
+++ ./beagle-0.2.17/beagled/FileSystemQueryable/FileSystemQueryable.cs 2007-07-13 08:57:55.000000000 +0200
@@ -149,6 +149,8 @@
foreach (Property std_prop in Property.StandardFileProperties
(name, mutable))
indexable.AddProperty (std_prop);
+ //AddExtendedPropertiesToIndexable (indexable);
+
if (parent_id == Guid.Empty)
return;
@@ -173,6 +175,27 @@
indexable.LocalState ["Parent"] = parent;
}
+ public static void AddExtendedPropertiesToIndexable(Indexable indexable,string path)
+ {
+ string[] XProperties;
+ string[] XPropertyNames;
+ string XValue="";
+ string XProperty="";
+ XProperties=
Util.ExtendedAttribute.List(path,true);
+ if (XProperties.Length==0)
+ return;
+ for( int i=0; i < XProperties.Length ; i++)
+ {
+ XPropertyNames = XProperties[i].Split('.');
+ XProperty = XPropertyNames[XPropertyNames.Length-1];
+ XValue = Util.ExtendedAttribute.Get(path,XProperties[i],true);
+ Property prop=Property.New("xattr:"+XProperty,XValue);
+ prop.IsMutable=true;
+ indexable.AddProperty(prop);
+ }
+
+ }
+
public static Indexable DirectoryToIndexable (string path,
Guid id,
DirectoryModel parent)
@@ -195,6 +218,7 @@
else
name = Path.GetFileName (path);
AddStandardPropertiesToIndexable (indexable, name, parent, true);
+ AddExtendedPropertiesToIndexable (indexable, path);
Property prop;
prop = Property.NewBool (Property.IsDirectoryPropKey, true);
@@ -226,6 +250,7 @@
indexable.Filtering = Beagle.IndexableFiltering.Always;
AddStandardPropertiesToIndexable (indexable, Path.GetFileName (path), parent, true);
+ AddExtendedPropertiesToIndexable (indexable, path);
indexable.LocalState ["Path"] = path;
@@ -242,6 +267,7 @@
indexable.DisplayUri = UriFu.PathToFileUri (name);
AddStandardPropertiesToIndexable (indexable, name, parent, true);
+ AddExtendedPropertiesToIndexable (indexable, name);
indexable.LocalState ["Id"] = id;
indexable.LocalState ["LastKnownPath"] = last_known_path;
@@ -895,6 +921,12 @@
return RequiredAction.Index;
}
}
+
+ /*if (attr.XPropertyCount != Util.ExtendedAttribute.Count(path)) {
+ if (Debug)
+ Logger.Log.Debug ("*** Index it: ExtendedAttributes has canged!");
+ return RequiredAction.Index;
+ }*/
Mono.Unix.Native.Stat stat;
try {
@@ -1152,6 +1184,51 @@
// FIXME: And now AddType no longer exists
ThisScheduler.Add (task);
}
+
+ public void UpdateAttributes(DirectoryModel dir, string name)
+ {
+ Indexable indexable;
+ Guid unique_id;
+ string path=Path.Combine(dir.FullName,name);
+
+ if (! File.Exists (path))
+ return;
+
+ if (FileSystem.IsSpecialFile (path))
+ return;
+
+ if (filter.Ignore (dir, name, false))
+ return;
+
+ unique_id = NameAndParentToId (name, dir);
+
+ indexable = new Indexable (IndexableType.PropertyChange, GuidFu.ToUri (unique_id));
+
+ // If the file was deleted, bail out.
+ if (! FileSystem.ExistsByDateTime (indexable.Timestamp))
+ return;
+
+
indexable.Timestamp = File.GetLastWriteTimeUtc (path);
+
+ indexable.ContentUri = UriFu.PathToFileUri (path);
+ indexable.DisplayUri = UriFu.PathToFileUri (path);
+ indexable.Crawled = true;
+ indexable.Filtering = Beagle.IndexableFiltering.Always;
+ indexable.LocalState ["LastKnownPath"] = path;
+
indexable.LocalState ["Path"] = path;
+
+ AddExtendedPropertiesToIndexable (indexable, path);
+
+ Scheduler.Task task;
+ task = NewAddTask (indexable);
+ task.Priority = Scheduler.Priority.Immediate;
+ // Danger Will Robinson!
+ // We need to use BlockUntilNoCollision to get the correct notifications
+ // in a mv a b; mv b c; mv c a situation.
+ // FIXME: And now AddType no longer exists
+ ThisScheduler.Add (task);
+
+ }
//////////////////////////////////////////////////////////////////////////
@@ -1297,6 +1374,7 @@
attr.FilterName = receipt.FilterName;
attr.FilterVersion
= receipt.FilterVersion;
+ attr.XPropertyCount= Util.ExtendedAttribute.Count(path);
if (indexable.LocalState ["IsWalkable"] != null) {
string name;
@@ -1480,6 +1558,17 @@
Logger.Log.Debug ("Saw event in '{0}'", directory_name);
}
+ public void HandleAttribEvent(string directory_name,string file_name, bool is_directory)
+ {
+ DirectoryModel dir;
+ dir = GetDirectoryModelByPath (directory_name);
+ if (!is_directory && file_name!=null && dir!=null){
+ Logger.Log.Debug
("*** Update Attributes '{0}' '{1}' {2}", directory_name, file_name,
+ is_directory ? "(dir)" : "(file)");
+ UpdateAttributes(dir,file_name);
+ }
+ }
+
public void HandleAddEvent (string directory_name, string file_name, bool is_directory)
{
Logger.Log.Debug ("*** Add '{0}' '{1}' {2}", directory_name, file_name,
--- ./beagle-0.2.17-orig/beagled/FileSystemQueryable/InotifyBackend.cs 2007-03-15 21:09:49.000000000 +0100
+++ ./beagle-0.2.17/beagled/FileSystemQueryable/InotifyBackend.cs 2007-07-11 13:23:43.000000000
+0200
@@ -52,7 +52,8 @@
| Inotify.EventType.Delete
| Inotify.EventType.CloseWrite
| Inotify.EventType.MovedFrom
- | Inotify.EventType.MovedTo);
+ | Inotify.EventType.MovedTo
+ | Inotify.EventType.Attrib);
}
catch (IOException) {
@@ -136,6 +137,11 @@
queryable.HandleOverflowEvent ();
return;
}
+
+ if ((type & Inotify.EventType.Attrib) != 0) {
+
queryable.HandleAttribEvent(path, subitem, is_directory);
+ return;
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]