summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2023-04-08 22:41:58 +0100
committerAntónio Fernandes <antoniof@gnome.org>2023-04-15 07:28:04 +0000
commit8ba2ebb450ea70159a8afe3d6995eec7f1fc8d67 (patch)
treef97bb63c58171760a447be0bc831262555f0c1c3
parented2dbd69b8bbdd98c3c09447087e8015c5d011f0 (diff)
downloadnautilus-8ba2ebb450ea70159a8afe3d6995eec7f1fc8d67.tar.gz
search-engine-tracker: Don't try to parse NULL time strings
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.c45
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..88bd376c2 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 atime: %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);