[rygel] media-export: Implement fallback to slow search
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Implement fallback to slow search
- Date: Mon, 12 Jul 2010 14:44:48 +0000 (UTC)
commit 7e04310ebda8f1a726e420fa33788abb273287b8
Author: Jens Georg <mail jensge org>
Date: Fri Jun 25 19:14:40 2010 +0200
media-export: Implement fallback to slow search
.../rygel-media-export-db-container.vala | 16 +++++++++++++-
.../rygel-media-export-media-cache.vala | 4 +-
.../rygel-media-export-query-container.vala | 23 ++++++++++++++-----
3 files changed, 34 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-db-container.vala b/src/plugins/media-export/rygel-media-export-db-container.vala
index 55ae2f5..68bff75 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -72,17 +72,31 @@ public class Rygel.MediaExport.DBContainer : MediaContainer {
out uint total_matches,
Cancellable? cancellable)
throws GLib.Error {
+ Gee.List<MediaObject> children = null;
+
var max_objects = max_count;
if (max_objects == 0) {
max_objects = -1;
}
- var children = this.media_db.get_objects_by_search_expression (
+ try {
+ children = this.media_db.get_objects_by_search_expression (
expression,
this.id,
offset,
max_objects,
out total_matches);
+ } catch (MediaDBError error) {
+ if (error is MediaDBError.UNSUPPORTED_SEARCH) {
+ children = yield base.search (expression,
+ offset,
+ max_count,
+ out total_matches,
+ cancellable);
+ } else {
+ throw error;
+ }
+ }
return children;
}
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index c649d48..5e10d46 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -29,7 +29,7 @@ public errordomain Rygel.MediaDBError {
SQLITE_ERROR,
GENERAL_ERROR,
INVALID_TYPE,
- UNSUPPORTED
+ UNSUPPORTED_SEARCH
}
public enum Rygel.MediaDBObjectType {
@@ -781,7 +781,7 @@ public class Rygel.MediaExport.MediaCache : Object {
default:
var message = "Unsupported column %s".printf (operand);
- throw new MediaDBError.UNSUPPORTED (message);
+ throw new MediaDBError.UNSUPPORTED_SEARCH (message);
}
return column;
diff --git a/src/plugins/media-export/rygel-media-export-query-container.vala b/src/plugins/media-export/rygel-media-export-query-container.vala
index 02cd3df..e009e82 100644
--- a/src/plugins/media-export/rygel-media-export-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container.vala
@@ -153,6 +153,8 @@ internal class Rygel.MediaExport.QueryContainer : DBContainer {
out uint total_matches,
Cancellable? cancellable)
throws GLib.Error {
+ Gee.List<MediaObject> children = null;
+
var combined_expression = new LogicalExpression ();
combined_expression.operand1 = this.expression;
combined_expression.op = LogicalOperator.AND;
@@ -163,12 +165,21 @@ internal class Rygel.MediaExport.QueryContainer : DBContainer {
max_objects = -1;
}
- var children = this.media_db.get_objects_by_search_expression (
- combined_expression,
- "0",
- offset,
- max_objects,
- out total_matches);
+ try {
+ children = this.media_db.get_objects_by_search_expression (
+ combined_expression,
+ "0",
+ offset,
+ max_objects,
+ out total_matches);
+ } catch (MediaDBError error) {
+ if (error is MediaDBError.UNSUPPORTED_SEARCH) {
+ children = new ArrayList<MediaObject> ();
+ total_matches = 0;
+ } else {
+ throw error;
+ }
+ }
return children;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]