[gnome-photos/wip/rishi/view-model: 3/5] item-manager: Fix logic to check if a cursor is a collection



commit e9572bdff68652996b052011b8a945b428be555b
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 24 11:05:58 2016 +0200

    item-manager: Fix logic to check if a cursor is a collection
    
    Some collections might not have a nao:identifier. eg., the built-in
    nfo:image-category-screenshot. Instead, we should check the rdf:type
    for nfo:DataContainer. This is also what PhotosBaseItem does.
    
    This wasn't a problem so far because we were miraculously not hitting
    this code path for such collections. Things are going to change in
    subsequent commits when we sprinkle some assertions around the code.

 src/photos-item-manager.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 924d08f..6634888 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -25,6 +25,8 @@
 
 #include "config.h"
 
+#include <string.h>
+
 #include <gio/gio.h>
 #include <glib.h>
 #include <tracker-sparql.h>
@@ -263,10 +265,10 @@ static gboolean
 photos_item_manager_cursor_is_collection (TrackerSparqlCursor *cursor)
 {
   gboolean ret_val;
-  const gchar *identifier;
+  const gchar *rdf_type;
 
-  identifier = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_IDENTIFIER, NULL);
-  ret_val = g_str_has_prefix (identifier, "photos:collection:");
+  rdf_type = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_RDF_TYPE, NULL);
+  ret_val = strstr (rdf_type, "nfo#DataContainer") != NULL;
   return ret_val;
 }
 


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