[tracker/tracker-0.6] Add a File:Added field, representing the date when the item as added to the DB.



commit eeff95507be5062d2299a011f1a4dab07b666579
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu May 28 17:06:02 2009 +0200

    Add a File:Added field, representing the date when the item as added to the DB.
    
    In order not to incorrectly represent old items as "recent" on reindex.
    File:Added will contain the mtime of the file when it's first added, and will
    remain unchanged if the file changes.
---
 data/services/file.metadata                        |   10 +++++++++-
 .../tracker-module-metadata-utils.c                |    4 ++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/data/services/file.metadata b/data/services/file.metadata
index 440d90e..063c168 100644
--- a/data/services/file.metadata
+++ b/data/services/file.metadata
@@ -81,11 +81,19 @@ FieldName=IndexTime
 
 [File:Accessed]
 DisplayName=Accessed
-Description=Last acessed date
+Description=Last accessed date
 DataType=date
 Parent=DC:Date
 FieldName=Accessed
 
+[File:Added]
+DisplayName=Added
+Description=Date of insertion to Tracker DB
+DataType=date
+Parent=DC:Date
+FieldName=Added
+Embedded=false
+
 [File:Other]
 DisplayName=Other
 Description=Other details about a file
diff --git a/src/tracker-indexer/tracker-module-metadata-utils.c b/src/tracker-indexer/tracker-module-metadata-utils.c
index 4412b2f..00c0a5e 100644
--- a/src/tracker-indexer/tracker-module-metadata-utils.c
+++ b/src/tracker-indexer/tracker-module-metadata-utils.c
@@ -49,6 +49,7 @@
 #define METADATA_FILE_SIZE           "File:Size"
 #define METADATA_FILE_MODIFIED       "File:Modified"
 #define METADATA_FILE_ACCESSED       "File:Accessed"
+#define METADATA_FILE_ADDED          "File:Added"
 
 #undef  TRY_LOCALE_TO_UTF8_CONVERSION
 #define TEXT_MAX_SIZE                1048576  /* bytes */
@@ -874,6 +875,9 @@ tracker_module_metadata_utils_get_data (GFile *file)
 	tracker_module_metadata_add_date (metadata, METADATA_FILE_MODIFIED, st.st_mtime);
 	tracker_module_metadata_add_date (metadata, METADATA_FILE_ACCESSED, st.st_atime);
 
+	/* Set mtime as addition date, so we don't report older files as "recent" on reindex */
+	tracker_module_metadata_add_date (metadata, METADATA_FILE_ADDED, st.st_mtime);
+
 	metadata_utils_get_embedded (file, mime_type, metadata);
 
 	g_free (mime_type);



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