[rygel/rygel-0-18] media-export: Really don't lose child containers
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/rygel-0-18] media-export: Really don't lose child containers
- Date: Mon, 13 May 2013 09:23:42 +0000 (UTC)
commit e9090d42bf5cda3a470055d12a257cff65aa2d27
Author: Jens Georg <jensg openismus com>
Date: Sun May 12 13:57:18 2013 +0200
media-export: Really don't lose child containers
The previous patch left over some stuff, cluttering virtual folders
Conflicts:
src/plugins/media-export/rygel-media-export-sql-factory.vala
.../media-export/rygel-media-export-harvester.vala | 11 +++++++++++
.../rygel-media-export-media-cache.vala | 10 +---------
.../rygel-media-export-root-container.vala | 17 ++++++++++-------
.../rygel-media-export-sql-factory.vala | 8 +-------
4 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala
b/src/plugins/media-export/rygel-media-export-harvester.vala
index 5f3f67a..b8000de 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -77,6 +77,17 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
}
/**
+ * Schedule rescan of all top-level locations known to the harvester.
+ *
+ * @param parent top-level container of the files
+ */
+ public void schedule_locations (MediaContainer parent) {
+ foreach (var file in this.locations) {
+ this.schedule (file, parent);
+ }
+ }
+
+ /**
* Put a file on queue for meta-data extraction
*
* @param file the file to investigate
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 34b1bb7..3267a01 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -62,7 +62,6 @@ public class Rygel.MediaExport.MediaCache : Object {
this.sql = new SQLFactory ();
this.open_db ("media-export");
this.factory = new ObjectFactory ();
- this.get_exists_cache ();
}
// Public static functions
@@ -87,13 +86,6 @@ public class Rygel.MediaExport.MediaCache : Object {
this.db.exec (this.sql.make (SQLString.DELETE), values);
}
- public void remove_by_id_from_parent (string id, string parent_id)
- throws DatabaseError {
- GLib.Value[] values = { id, parent_id };
- this.db.exec (this.sql.make (SQLString.DELETE_BY_ID_FROM_PARENT),
- values);
- }
-
public void remove_object (MediaObject object) throws DatabaseError,
MediaCacheError {
this.remove_by_id (object.id);
@@ -541,7 +533,7 @@ public class Rygel.MediaExport.MediaCache : Object {
}
}
- private void get_exists_cache () throws DatabaseError {
+ public void rebuild_exists_cache () throws DatabaseError {
this.exists_cache = new HashMap<string, ExistsCacheEntry?> ();
var cursor = this.exec_cursor (SQLString.EXISTS_CACHE);
foreach (var statement in cursor) {
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala
b/src/plugins/media-export/rygel-media-export-root-container.vala
index 2357c2a..4b00bc5 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -414,11 +414,9 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
(on_initial_harvesting_done);
// For each location that we want the harvester to scan,
- // remove it from the cache and request a rescan.
+ // remove it from the cache.
foreach (var file in this.harvester.locations) {
ids.remove (MediaCache.get_id (file));
- this.harvester.schedule (file,
- this.filesystem_container);
}
// Warn about any top-level locations that were known to
@@ -427,16 +425,21 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
foreach (var id in ids) {
debug ("ID %s is no longer in the configuration. Deleting...", id);
try {
- // Remove IDs only if it's a parent of the toplevel folder.
- // Keep it otherwise.
- this.media_db.remove_by_id_from_parent (id,
- FILESYSTEM_FOLDER_ID);
// FIXME: I think this needs to emit objDel events...
+ this.media_db.remove_by_id (id);
} catch (DatabaseError error) {
warning (_("Failed to remove entry: %s"), error.message);
}
}
+ // Before we start (re-)scanning, create a cache with all mtimes. This
+ // is done here in case we removed ids from above so we make sure we
+ // re-visit everything.
+ this.media_db.rebuild_exists_cache ();
+
+ // Request a rescan of all top-level locations.
+ this.harvester.schedule_locations (this.filesystem_container);
+
// We have removed some uris so we notify that the root container has
// changed
if (!ids.is_empty) {
diff --git a/src/plugins/media-export/rygel-media-export-sql-factory.vala
b/src/plugins/media-export/rygel-media-export-sql-factory.vala
index 1127c61..42b6201 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -76,8 +76,7 @@ internal enum Rygel.MediaExport.SQLString {
MAX_UPDATE_ID,
MAKE_GUARDED,
IS_GUARDED,
- UPDATE_GUARDED_OBJECT,
- DELETE_BY_ID_FROM_PARENT
+ UPDATE_GUARDED_OBJECT
}
internal class Rygel.MediaExport.SQLFactory : Object {
@@ -295,9 +294,6 @@ internal class Rygel.MediaExport.SQLFactory : Object {
private const string IS_GUARDED_STRING =
"SELECT is_guarded FROM Object WHERE Object.upnp_id = ?";
- private const string DELETE_BY_ID_FROM_PARENT_STRING =
- "DELETE FROM Object WHERE upnp_id = ? AND parent = ?";
-
public unowned string make (SQLString query) {
switch (query) {
case SQLString.SAVE_METADATA:
@@ -352,8 +348,6 @@ internal class Rygel.MediaExport.SQLFactory : Object {
return IS_GUARDED_STRING;
case SQLString.UPDATE_GUARDED_OBJECT:
return UPDATE_GUARDED_OBJECT_STRING;
- case SQLString.DELETE_BY_ID_FROM_PARENT:
- return DELETE_BY_ID_FROM_PARENT_STRING;
default:
assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]