[tracker/wip/carlosg/graphs: 1/12] libtracker-data: Fix retrieval of old datetime values for updates
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/graphs: 1/12] libtracker-data: Fix retrieval of old datetime values for updates
- Date: Wed, 29 Apr 2020 20:33:06 +0000 (UTC)
commit f022da229a0d882b23f0d51b92214547674571c4
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 23 11:31:58 2020 +0200
libtracker-data: Fix retrieval of old datetime values for updates
Commit 542e1254e4f changed datetime storage so we don't resort to
tricks with doubles to store sub-second precision. The code retrieving
old values for INSERT/UPDATE handling was missed, leading to warnings
trying to cast the contained string to a double.
Dates are either unix timestamps (ints) or iso8601 dates (strings),
deal properly with the latter.
src/libtracker-data/tracker-data-update.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index f756aadc2..7bd532fd8 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1426,17 +1426,28 @@ get_property_values (TrackerData *data,
if (G_VALUE_TYPE (&gvalue)) {
if (tracker_property_get_data_type (property) ==
TRACKER_PROPERTY_TYPE_DATETIME) {
- gdouble time;
-
if (G_VALUE_TYPE (&gvalue) == G_TYPE_INT64) {
+ gdouble time;
+
time = g_value_get_int64 (&gvalue);
+ g_value_unset (&gvalue);
+ g_value_init (&gvalue, TRACKER_TYPE_DATE_TIME);
+ /* UTC offset is irrelevant for comparison */
+ tracker_date_time_set (&gvalue, time, 0);
} else {
- time = g_value_get_double (&gvalue);
+ gchar *time;
+
+ time = g_value_dup_string (&gvalue);
+ g_value_unset (&gvalue);
+ g_value_init (&gvalue, TRACKER_TYPE_DATE_TIME);
+ tracker_date_time_set_from_string (&gvalue, time,
&error);
+ g_free (time);
+
+ if (error) {
+ g_warning ("Error in date conversion: %s",
error->message);
+ g_error_free (error);
+ }
}
- g_value_unset (&gvalue);
- g_value_init (&gvalue, TRACKER_TYPE_DATE_TIME);
- /* UTC offset is irrelevant for comparison */
- tracker_date_time_set (&gvalue, time, 0);
}
g_array_append_val (old_values, gvalue);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]