[tracker-miners/wip/carlosg/time_t] tracker-miner-fs: Interpret GFileInfo times as time_t




commit 5754debe426faa0f115441e756fa9aa2d265155b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 16 11:42:16 2020 +0100

    tracker-miner-fs: Interpret GFileInfo times as time_t
    
    This is a time_t underneath, and forcibly interpreting it as unsigned
    will break with negative times on platforms that internally define that
    type as signed (Linux and the GNU C library between them).
    
    Deal with it as a time_t on our side, and let up to the underlying
    implementation the interpretation of negative timestamps.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/155

 src/miners/fs/tracker-miner-files.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 8b55c0251..4dfff6854 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2064,7 +2064,7 @@ miner_files_process_file (TrackerMinerFS      *fs,
        const gchar *mime_type, *graph;
        gchar *parent_urn;
        gchar *delete_properties_sparql = NULL;
-       guint64 time_;
+       time_t time_;
        GFile *parent;
        gchar *uri, *time_str;
        gboolean is_directory;
@@ -2119,12 +2119,12 @@ miner_files_process_file (TrackerMinerFS      *fs,
        tracker_resource_set_int64 (resource, "nfo:fileSize",
                                    g_file_info_get_size (file_info));
 
-       time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+       time_ = (time_t) g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
        time_str = tracker_date_to_string (time_);
        tracker_resource_set_string (resource, "nfo:fileLastModified", time_str);
        g_free (time_str);
 
-       time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_ACCESS);
+       time_ = (time_t) g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_ACCESS);
        time_str = tracker_date_to_string (time_);
        tracker_resource_set_string (resource, "nfo:fileLastAccessed", time_str);
        g_free (time_str);
@@ -2151,7 +2151,7 @@ miner_files_process_file (TrackerMinerFS      *fs,
                graph_file = tracker_resource_new (uri);
                tracker_resource_add_uri (graph_file, "rdf:type", "nfo:FileDataObject");
 
-               time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+               time_ = (time_t) g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
                time_str = tracker_date_to_string (time_);
                tracker_resource_set_string (graph_file, "nfo:fileLastModified", time_str);
                g_free (time_str);
@@ -2180,7 +2180,7 @@ miner_files_process_file_attributes (TrackerMinerFS      *fs,
                                      TrackerSparqlBuffer *buffer)
 {
        TrackerResource *resource;
-       guint64 time_;
+       time_t time_;
        gchar *uri, *time_str;
 
        uri = g_file_get_uri (file);
@@ -2195,13 +2195,13 @@ miner_files_process_file_attributes (TrackerMinerFS      *fs,
        }
 
        /* Update nfo:fileLastModified */
-       time_ = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+       time_ = (time_t) g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
        time_str = tracker_date_to_string (time_);
        tracker_resource_set_string (resource, "nfo:fileLastModified", time_str);
        g_free (time_str);
 
        /* Update nfo:fileLastAccessed */
-       time_ = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
+       time_ = (time_t) g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
        time_str = tracker_date_to_string (time_);
        tracker_resource_set_string (resource, "nfo:fileLastAccessed", time_str);
        g_free (time_str);


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