diff options
author | António Fernandes <antoniof@gnome.org> | 2023-04-08 22:41:58 +0100 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2023-04-08 22:41:58 +0100 |
commit | 41d997680250cdb7828481cb300c09bb4f0fe16e (patch) | |
tree | 45897446c7a42f078bf8b76eb67e90b86e5e1051 | |
parent | 1135937b60fbf962c473989268887e8dc912567a (diff) | |
download | nautilus-wip/antoniof/null-date-from-tracker.tar.gz |
search-engine-tracker: Don't try to parse NULL time stringswip/antoniof/null-date-from-tracker
TrackerCursor returns NULL if it doesn't have information on the date.
https://gnome.pages.gitlab.gnome.org/tracker/docs/developer/method.SparqlCursor.get_string.html
We try to parse NULL as a date string. This is obviously wrong and
gets us a precondition failure warning, as it should.
So, if a string is NULL, just skip it.
Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2160
-rw-r--r-- | src/nautilus-search-engine-tracker.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c index 51917216b..82fb35ff3 100644 --- a/src/nautilus-search-engine-tracker.c +++ b/src/nautilus-search-engine-tracker.c @@ -181,7 +181,6 @@ cursor_callback (GObject *object, const char *atime_str; const char *ctime_str; const gchar *snippet; - GDateTime *date; g_autoptr (GTimeZone) tz = g_time_zone_new_local (); gdouble rank, match; gboolean success; @@ -232,35 +231,37 @@ cursor_callback (GObject *object, } } - date = g_date_time_new_from_iso8601 (mtime_str, tz); - if (date != NULL) + if (mtime_str != NULL) { + g_autoptr (GDateTime) date = g_date_time_new_from_iso8601 (mtime_str, tz); + + if (date == NULL) + { + g_warning ("unable to parse mtime: %s", mtime_str); + } nautilus_search_hit_set_modification_time (hit, date); - g_date_time_unref (date); - } - else - { - g_warning ("unable to parse mtime: %s", mtime_str); } - date = g_date_time_new_from_iso8601 (atime_str, tz); - if (date != NULL) + + if (atime_str != NULL) { + g_autoptr (GDateTime) date = g_date_time_new_from_iso8601 (atime_str, tz); + + if (date == NULL) + { + g_warning ("unable to parse mtime: %s", atime_str); + } nautilus_search_hit_set_access_time (hit, date); - g_date_time_unref (date); } - else - { - g_warning ("unable to parse atime: %s", atime_str); - } - date = g_date_time_new_from_iso8601 (ctime_str, tz); - if (date != NULL) + + if (ctime_str != NULL) { + g_autoptr (GDateTime) date = g_date_time_new_from_iso8601 (ctime_str, tz); + + if (date == NULL) + { + g_warning ("unable to parse ctime: %s", ctime_str); + } nautilus_search_hit_set_creation_time (hit, date); - g_date_time_unref (date); - } - else - { - g_warning ("unable to parse ctime: %s", ctime_str); } g_queue_push_head (tracker->hits_pending, hit); |