[tracker] libtracker-miner: Ignore mtime difference of less than 2 seconds
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-miner: Ignore mtime difference of less than 2 seconds
- Date: Thu, 20 Oct 2011 13:48:32 +0000 (UTC)
commit e60fc84e6a785022dfb535405bfadbe17f927027
Author: JÃrg Billeter <j bitron ch>
Date: Thu Oct 20 13:12:53 2011 +0200
libtracker-miner: Ignore mtime difference of less than 2 seconds
FAT stores timestamps with 2 second granularity.
Fixes NB#287278.
src/libtracker-miner/tracker-miner-fs.c | 35 +++++++++++++++----------------
1 files changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 7e5328c..104db35 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -19,6 +19,7 @@
#include "config.h"
+#include <libtracker-common/tracker-date-time.h>
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-log.h>
@@ -3423,9 +3424,9 @@ should_change_index_for_file (TrackerMinerFS *fs,
{
GFileInfo *file_info;
guint64 time;
- time_t mtime;
- struct tm t;
- gchar *time_str, *lookup_time;
+ time_t mtime, lookup_mtime;
+ gchar *lookup_time;
+ GError *error = NULL;
/* Make sure mtime cache contains the mtimes of all files in the
* same directory as the given file
@@ -3444,6 +3445,14 @@ should_change_index_for_file (TrackerMinerFS *fs,
return TRUE;
}
+ lookup_mtime = tracker_string_to_date (lookup_time, NULL, &error);
+ if (error) {
+ /* This should never happen. Assume that file was modified. */
+ g_critical ("should_change_index_for_file: %s", error->message);
+ g_clear_error (&error);
+ return TRUE;
+ }
+
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@@ -3460,24 +3469,14 @@ should_change_index_for_file (TrackerMinerFS *fs,
mtime = (time_t) time;
g_object_unref (file_info);
- gmtime_r (&mtime, &t);
-
- time_str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02dZ",
- t.tm_year + 1900,
- t.tm_mon + 1,
- t.tm_mday,
- t.tm_hour,
- t.tm_min,
- t.tm_sec);
-
- if (strcmp (time_str, lookup_time) == 0) {
- /* File already up-to-date in the database */
- g_free (time_str);
+ if (abs (mtime - lookup_mtime) < 2) {
+ /* File already up-to-date in the database
+ * accept 1 second difference as FAT stores timestamps
+ * with 2 second granularity
+ */
return FALSE;
}
- g_free (time_str);
-
/* File either not yet in the database or mtime is different
* Update in database required
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]