[rygel] media-export: Be able to use in-memory database
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Be able to use in-memory database
- Date: Fri, 5 Apr 2013 12:56:44 +0000 (UTC)
commit 53e27b7217125b682ccfccd56cfaaa6e4a7fbe4b
Author: Jens Georg <mail jensge org>
Date: Wed Aug 25 20:09:04 2010 +0300
media-export: Be able to use in-memory database
Useful for unittests
.../media-export/rygel-media-export-database.vala | 15 +++++++++++----
.../rygel-media-export-media-cache.vala | 9 ++++++++-
2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-database.vala
b/src/plugins/media-export/rygel-media-export-database.vala
index 16c007d..1b2f3d3 100644
--- a/src/plugins/media-export/rygel-media-export-database.vala
+++ b/src/plugins/media-export/rygel-media-export-database.vala
@@ -87,10 +87,17 @@ internal class Rygel.MediaExport.Database : SqliteWrapper {
* (<cache-dir>/rygel/<name>.db)
*/
public Database (string name) throws DatabaseError {
- var dirname = Path.build_filename (Environment.get_user_cache_dir (),
- "rygel");
- DirUtils.create_with_parents (dirname, 0750);
- var db_file = Path.build_filename (dirname, "%s.db".printf (name));
+ string db_file;
+
+ if (name != ":memory:") {
+ var dirname = Path.build_filename (
+ Environment.get_user_cache_dir (),
+ "rygel");
+ DirUtils.create_with_parents (dirname, 0750);
+ db_file = Path.build_filename (dirname, "%s.db".printf (name));
+ } else {
+ db_file = name;
+ }
base (db_file);
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 084e9c0..e904cca 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -59,8 +59,15 @@ public class Rygel.MediaExport.MediaCache : Object {
// Constructors
private MediaCache () throws Error {
+ var db_name = "media-export";
+ try {
+ var config = MetaConfig.get_default ();
+ if (config.get_bool ("MediaExport", "use-temp-db")) {
+ db_name = ":memory:";
+ }
+ } catch (Error error) { }
this.sql = new SQLFactory ();
- this.open_db ("media-export");
+ this.open_db (db_name);
this.factory = new ObjectFactory ();
this.get_exists_cache ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]