[tracker/sam/diagrams: 4/9] Give clearer warning for missing nfo:fileLastModified



commit cfa204eb01d0ce2f64472dcb107a401f63176abe
Author: Sam Thursfield <sam afuera me uk>
Date:   Tue Dec 23 16:00:22 2014 +0000

    Give clearer warning for missing nfo:fileLastModified
    
    This error should be rare after the previous commit, but it's still
    possible.

 src/libtracker-miner/tracker-file-notifier.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 19594c0..49ae5c1 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -500,11 +500,12 @@ sparql_files_query_populate (TrackerFileNotifier *notifier,
 
        while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
                GFile *file, *canonical, *root;
-               const gchar *time_str, *iri;
+               const gchar *time_str, *uri, *iri;
                GError *error = NULL;
                guint64 _time;
 
-               file = g_file_new_for_uri (tracker_sparql_cursor_get_string (cursor, 0, NULL));
+               uri = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+               file = g_file_new_for_uri (uri);
 
                if (check_root) {
                        /* If it's a config root itself, other than the one
@@ -523,7 +524,19 @@ sparql_files_query_populate (TrackerFileNotifier *notifier,
 
                iri = tracker_sparql_cursor_get_string (cursor, 1, NULL);
                time_str = tracker_sparql_cursor_get_string (cursor, 2, NULL);
-               _time = tracker_string_to_date (time_str, NULL, &error);
+
+               if (time_str == NULL) {
+                       /* This can happen if someone inserted the file's metadata in the store using INSERT
+                        * statements, rather than going through the FS miner. Or if for some reason they
+                        * deleted the nfo:fileLastModified information. We report the store_mtime of the
+                        * file as 0 so that it will get recrawled, if it is still present on disk, in
+                        * file_notifier_traverse_tree_foreach().
+                        */
+                       g_warning ("File %s has no nfo:fileLastModified time set.", uri);
+                       _time = 0;
+               } else {
+                       _time = tracker_string_to_date (time_str, NULL, &error);
+               }
 
                if (error) {
                        /* This should never happen. Assume that file was modified. */


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