Commit df2ba503 authored by Debarshi Ray's avatar Debarshi Ray

base-item, utils: Split out the code to get mtime from SparqlCursor

The subsequent commit will use this elsewhere in the codebase to avoid
a CRITICAL.

!149
parent 9b4ab3d9
......@@ -2769,7 +2769,6 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
const gchar *identifier;
const gchar *location;
const gchar *mime_type;
const gchar *mtime;
const gchar *orientation;
const gchar *rdf_type;
const gchar *resource_urn;
......@@ -2807,18 +2806,7 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
favorite = tracker_sparql_cursor_get_boolean (cursor, PHOTOS_QUERY_COLUMNS_RESOURCE_FAVORITE);
priv->mtime = -1;
mtime = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_MTIME, NULL);
if (mtime != NULL)
{
g_autoptr (GDateTime) date_modified = NULL;
date_modified = g_date_time_new_from_iso8601 (mtime, NULL);
if (date_modified != NULL)
priv->mtime = g_date_time_to_unix (date_modified);
}
if (priv->mtime == -1)
priv->mtime = g_get_real_time () / 1000000;
priv->mtime = photos_utils_get_mtime_from_sparql_cursor (cursor);
g_object_notify (G_OBJECT (self), "mtime");
mime_type = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_MIME_TYPE, NULL);
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2012 – 2019 Red Hat, Inc.
* Copyright © 2012 – 2020 Red Hat, Inc.
* Copyright © 2009 Yorba Foundation
*
* This program is free software: you can redistribute it and/or modify
......@@ -971,6 +971,29 @@ photos_utils_get_icon_size_unscaled (void)
}
gint64
photos_utils_get_mtime_from_sparql_cursor (TrackerSparqlCursor *cursor)
{
const gchar *mtime_str;
gint64 mtime = -1;
mtime_str = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_MTIME, NULL);
if (mtime_str != NULL)
{
g_autoptr (GDateTime) date_modified = NULL;
date_modified = g_date_time_new_from_iso8601 (mtime_str, NULL);
if (date_modified != NULL)
mtime = g_date_time_to_unix (date_modified);
}
if (mtime == -1)
mtime = g_get_real_time () / 1000000;
return mtime;
}
gchar *
photos_utils_get_pixbuf_common_suffix (GdkPixbufFormat *format)
{
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2012 – 2019 Red Hat, Inc.
* Copyright © 2012 – 2020 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -134,6 +134,8 @@ gint photos_utils_get_icon_size (void);
gint photos_utils_get_icon_size_unscaled (void);
gint64 photos_utils_get_mtime_from_sparql_cursor (TrackerSparqlCursor *cursor);
char* photos_utils_get_pixbuf_common_suffix (GdkPixbufFormat *format);
const gchar *photos_utils_get_provider_name (PhotosBaseManager *src_mngr, PhotosBaseItem *item);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment