[patch] Add a timestamp to metafiles
- From: Joe Shaw <joeshaw novell com>
- To: nautilus-list gnome org
- Subject: [patch] Add a timestamp to metafiles
- Date: Fri, 29 Jul 2005 11:57:19 -0400
Hi,
For Beagle, we want to be able to index Nautilus metadata. Things like
emblems, notes, etc. This data is stored per-directory in files in
~/.nautilus/metafiles. Unfortunately the data isn't timestamped, so
while we can monitor these files using inotify, if one changes we have
to reindex every file in the directory that it points to. Indexing is
an expensive operation, so obviously we can't do this for directories
with more than a couple files.
The attached patch adds a timestamp attribute to the file nodes in the
XML file.
I've also filed this as a bug here:
http://bugzilla.gnome.org/show_bug.cgi?id=311903
Please CC me, I'm not on the list.
Thanks,
Joe
Index: libnautilus-private/nautilus-metafile.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metafile.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 nautilus-metafile.c
--- libnautilus-private/nautilus-metafile.c 22 Nov 2004 15:24:36 -0000 1.39
+++ libnautilus-private/nautilus-metafile.c 28 Jul 2005 21:56:11 -0000
@@ -42,6 +42,7 @@
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs.h>
#include <stdlib.h>
+#include <time.h>
#include <unistd.h>
#define METAFILE_XML_VERSION "1.0"
@@ -758,6 +759,17 @@ get_file_node (NautilusMetafile *metafil
return NULL;
}
+static void
+set_file_node_timestamp (xmlNode *node)
+{
+ char time_str[21];
+
+ /* 2^64 turns out to be 20 characters */
+ snprintf (time_str, 20, "%ld", time (NULL));
+ time_str [20] = '\0';
+ xmlSetProp (node, "timestamp", time_str);
+}
+
static char *
get_metadata_string_from_metafile (NautilusMetafile *metafile,
const char *file_name,
@@ -817,8 +829,11 @@ set_metadata_string_in_metafile (Nautilu
/* Get or create the node. */
node = get_file_node (metafile, file_name, value != NULL);
- /* Add or remove a property node. */
if (node != NULL) {
+ /* Set the timestamp */
+ set_file_node_timestamp (node);
+
+ /* Add or remove a property node. */
property_node = xmlSetProp (node, key, value);
if (value == NULL) {
xmlRemoveProp (property_node);
@@ -878,6 +893,9 @@ set_metadata_list_in_metafile (NautilusM
xmlSetProp (child, list_subkey, p->data);
changed = TRUE;
}
+
+ /* Set the timestamp */
+ set_file_node_timestamp (node);
}
if (!changed) {
@@ -1418,6 +1436,7 @@ copy_file_metadata (NautilusMetafile *so
root = create_metafile_root (destination_metafile);
xmlAddChild (root, node);
xmlSetProp (node, "name", destination_file_name);
+ set_file_node_timestamp (node);
g_hash_table_insert (destination_metafile->details->node_hash,
xmlMemStrdup (destination_file_name), node);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]