for (int i = 0; i < args.n_values; i++)
debug ("Arg %d: %s", i, args.get_nth(i).get_string());
- var children = this.media_db.get_children_with_filter (
- filter,
- args,
- this.id,
- offset,
- max_count == 0 ? -1 : max_count);
+ var children = this.media_db.get_objects_by_filter (
+ filter,
+ args,
+ this.id,
+ offset,
+ max_count == 0 ? -1 : max_count);
+ total_matches = children.size;
return children;
}
"o.title ASC " +
"LIMIT ?,?";
- private const string GET_CHILDREN_STRING_WITH_FILTER =
+ private const string GET_OBJECTS_STRING_WITH_FILTER =
"SELECT o.type_fk, o.title, m.size, m.mime_type, " +
"m.width, m.height, m.class, m.author, m.album, " +
"m.date, m.bitrate, m.sample_freq, m.bits_per_sample, " +
return children;
}
- public Gee.ArrayList<MediaObject> get_children_with_filter (
+ public Gee.ArrayList<MediaObject> get_objects_by_filter (
string filter,
GLib.ValueArray args,
string container_id,
Rygel.Database.RowCallback cb = (stmt) => {
var child_id = stmt.column_text (17);
var parent_id = stmt.column_text (18);
- var parent = (MediaContainer) get_object (parent_id);
- children.add (get_object_from_statement (parent,
- child_id,
- stmt));
- children[children.size - 1].parent = parent;
- children[children.size - 1].parent_ref = parent;
-
- return true;
+ try {
+ var parent = (MediaContainer) get_object (parent_id);
+ children.add (get_object_from_statement (parent,
+ child_id,
+ stmt));
+ children[children.size - 1].parent = parent;
+ children[children.size - 1].parent_ref = parent;
+
+ return true;
+ } catch (DatabaseError e) {
+ warning ("Failed to get parent item: %s", e.message);
+ return false;
+ }
};
- this.db.exec (GET_CHILDREN_STRING_WITH_FILTER.printf(filter), args.values, cb);
+ this.db.exec (GET_OBJECTS_STRING_WITH_FILTER.printf(filter), args.values, cb);
return children;
}
}