[gnome-online-miners] flickr: Use creation date as mtime



commit b319743b2274f3969f347ea7b1354ee0c447c445
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Jul 1 14:42:26 2013 +0200

    flickr: Use creation date as mtime
    
    The modification date is not available for Flickr, but applications
    need it to order the content. So lets use the creation date for that.

 src/gom-flickr-miner.c |   52 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 16 deletions(-)
---
diff --git a/src/gom-flickr-miner.c b/src/gom-flickr-miner.c
index f624d32..87d897c 100644
--- a/src/gom-flickr-miner.c
+++ b/src/gom-flickr-miner.c
@@ -97,12 +97,13 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
                                  FlickrEntry *entry,
                                  GError **error)
 {
-  GDateTime *created_time;
+  GDateTime *created_time, *modification_date;
   gchar *contact_resource;
   gchar *resource = NULL;
   gchar *date, *identifier;
   const gchar *class = NULL, *id, *mime, *name;
-  gboolean resource_exists;
+  gboolean resource_exists, mtime_changed;
+  gint64 new_mtime;
 
   if (op_type == OP_CREATE_HIEARCHY && entry->parent == NULL)
     return TRUE;
@@ -171,6 +172,39 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
   if (op_type == OP_CREATE_HIEARCHY)
     goto out;
 
+  /* only GRL_METADATA_KEY_CREATION_DATE is
+   * implemented, GRL_METADATA_KEY_MODIFICATION_DATE is not
+   */
+  created_time = modification_date = grl_media_get_creation_date (entry->media);
+  new_mtime = g_date_time_to_unix (modification_date);
+  mtime_changed = gom_tracker_update_mtime (job->connection, new_mtime,
+                                            resource_exists, identifier, resource,
+                                            job->cancellable, error);
+
+  if (*error != NULL)
+    goto out;
+
+  /* avoid updating the DB if the entry already exists and has not
+   * been modified since our last run.
+   */
+  if (!mtime_changed)
+    goto out;
+
+  /* the resource changed - just set all the properties again */
+  if (created_time != NULL)
+    {
+      date = gom_iso8601_from_timestamp (g_date_time_to_unix (created_time));
+      gom_tracker_sparql_connection_insert_or_replace_triple
+        (job->connection,
+         job->cancellable, error,
+         job->datasource_urn, resource,
+         "nie:contentCreated", date);
+      g_free (date);
+    }
+
+  if (*error != NULL)
+    goto out;
+
   gom_tracker_sparql_connection_insert_or_replace_triple
     (job->connection,
      job->cancellable, error,
@@ -232,20 +266,6 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
   if (*error != NULL)
     goto out;
 
-  created_time = grl_media_get_creation_date (entry->media);
-  if (created_time != NULL)
-    {
-      date = gom_iso8601_from_timestamp (g_date_time_to_unix (created_time));
-      gom_tracker_sparql_connection_insert_or_replace_triple
-        (job->connection,
-         job->cancellable, error,
-         job->datasource_urn, resource,
-         "nie:contentCreated", date);
-      g_free (date);
-    }
-  if (*error != NULL)
-    goto out;
-
  out:
   g_free (resource);
   g_free (identifier);


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