core: Prevent critical if URI exists
authorJens Georg <mail@jensge.org>
Thu, 13 Oct 2011 08:52:54 +0000 (10:52 +0200)
committerJens Georg <mail@jensge.org>
Thu, 13 Oct 2011 08:52:54 +0000 (10:52 +0200)
If the where clause does not match, there is no hash-table returned,
not an empty one.

src/plugins/tracker/rygel-tracker-insertion-query.vala

index 228feb2..29f8e56 100644 (file)
@@ -109,15 +109,14 @@ public class Rygel.Tracker.InsertionQuery : Query {
 
         var result = yield resources.sparql_update_blank (str);
 
-        this.id = result[0,0].lookup (TEMP_ID);
-
         // Item already existed
-        if (this.id == null) {
+        if (result[0,0] == null || result[0,0].lookup (TEMP_ID) == null)  {
             var ids = yield resources.sparql_query
                                         (this.get_resource_id_query ());
 
             this.id = ids[0,0];
         } else {
+            this.id = result[0,0].lookup (TEMP_ID);
             var file = File.new_for_uri (this.uri);
             if (file.is_native () &&
                 file.query_exists ()) {