~ubuntu-branches/ubuntu/raring/tracker/raring

« back to all changes in this revision

Viewing changes to src/libtracker-miner/tracker-miner-fs.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-10-21 16:42:59 UTC
  • mfrom: (4.4.28 experimental)
  • Revision ID: package-import@ubuntu.com-20111021164259-322n6i3db3icfyna
Tags: 0.12.6-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include "config.h"
21
21
 
 
22
#include <libtracker-common/tracker-date-time.h>
22
23
#include <libtracker-common/tracker-dbus.h>
23
24
#include <libtracker-common/tracker-file-utils.h>
24
25
#include <libtracker-common/tracker-log.h>
3423
3424
{
3424
3425
        GFileInfo          *file_info;
3425
3426
        guint64             time;
3426
 
        time_t              mtime;
3427
 
        struct tm           t;
3428
 
        gchar              *time_str, *lookup_time;
 
3427
        time_t              mtime, lookup_mtime;
 
3428
        gchar              *lookup_time;
 
3429
        GError             *error = NULL;
3429
3430
 
3430
3431
        /* Make sure mtime cache contains the mtimes of all files in the
3431
3432
         * same directory as the given file
3444
3445
                return TRUE;
3445
3446
        }
3446
3447
 
 
3448
        lookup_mtime = tracker_string_to_date (lookup_time, NULL, &error);
 
3449
        if (error) {
 
3450
                /* This should never happen. Assume that file was modified. */
 
3451
                g_critical ("should_change_index_for_file: %s", error->message);
 
3452
                g_clear_error (&error);
 
3453
                return TRUE;
 
3454
        }
 
3455
 
3447
3456
        file_info = g_file_query_info (file,
3448
3457
                                       G_FILE_ATTRIBUTE_TIME_MODIFIED,
3449
3458
                                       G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
3460
3469
        mtime = (time_t) time;
3461
3470
        g_object_unref (file_info);
3462
3471
 
3463
 
        gmtime_r (&mtime, &t);
3464
 
 
3465
 
        time_str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02dZ",
3466
 
                                    t.tm_year + 1900,
3467
 
                                    t.tm_mon + 1,
3468
 
                                    t.tm_mday,
3469
 
                                    t.tm_hour,
3470
 
                                    t.tm_min,
3471
 
                                    t.tm_sec);
3472
 
 
3473
 
        if (strcmp (time_str, lookup_time) == 0) {
3474
 
                /* File already up-to-date in the database */
3475
 
                g_free (time_str);
 
3472
        if (abs (mtime - lookup_mtime) < 2) {
 
3473
                /* File already up-to-date in the database
 
3474
                 * accept 1 second difference as FAT stores timestamps
 
3475
                 * with 2 second granularity
 
3476
                 */
3476
3477
                return FALSE;
3477
3478
        }
3478
3479
 
3479
 
        g_free (time_str);
3480
 
 
3481
3480
        /* File either not yet in the database or mtime is different
3482
3481
         * Update in database required
3483
3482
         */