[tracker-miners/tracker-miners-3.0] tracker-miner-fs: Interpret GFileInfo uint64 times as time_t



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

    tracker-miner-fs: Interpret GFileInfo uint64 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. This relies
    on undocumented implementation details and is thus a hack.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/155
    
    (cherry-picked from commit ebec93102c88db8378a5d23ab7e5441762a6bb26)

 src/miners/fs/tracker-miner-files.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 9ed6a8f05..3c04f41db 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2098,7 +2098,7 @@ process_file_cb (GObject      *object,
        gchar *parent_urn;
        gchar *delete_properties_sparql = NULL;
        GFileInfo *file_info;
-       guint64 time_;
+       time_t time_;
        GFile *file, *parent;
        gchar *uri, *sparql_str, *sparql_update_str, *time_str, *ie_update_str = NULL, *graph_file_str = NULL;
        GError *error = NULL;
@@ -2184,7 +2184,7 @@ process_file_cb (GObject      *object,
        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);
@@ -2300,7 +2300,7 @@ process_file_attributes_cb (GObject      *object,
        TrackerResource *resource;
        ProcessFileData *data;
        GFileInfo *file_info;
-       guint64 time_;
+       time_t time_;
        GFile *file;
        gchar *uri, *time_str, *sparql_str;
        GError *error = NULL;
@@ -2328,7 +2328,7 @@ process_file_attributes_cb (GObject      *object,
        g_free (time_str);
 
        /* Update nfo:fileLastAccessed */
-       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);


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