[rygel] media-export: Try to prevent crash when removing
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Try to prevent crash when removing
- Date: Thu, 5 Aug 2010 14:32:32 +0000 (UTC)
commit a162076fbba85108a103889479bad9d90c779e7c
Author: Jens Georg <mail jensge org>
Date: Sat Jul 24 23:29:38 2010 +0300
media-export: Try to prevent crash when removing
When uri is removed while harvesting, it could lead to a crash. now
harvesting is cancelled before removing the uri.
.../rygel-media-export-root-container.vala | 22 ++++++++++++-------
1 files changed, 14 insertions(+), 8 deletions(-)
---
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 f26c618..cdbb394 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -74,6 +74,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
var id = Checksum.compute_for_string (ChecksumType.MD5,
file.get_uri ());
+ cancel_harvester (file);
try {
this.media_db.remove_by_id (id);
} catch (Error error) {
@@ -355,6 +356,16 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
this.harvester_trash.remove (harvester);
}
+ private void cancel_harvester (File file) {
+ if (this.harvester.contains (file)) {
+ var harvester = this.harvester[file];
+ harvester.harvested.disconnect (this.on_file_harvested);
+ harvester.cancellable.cancel ();
+ harvester.harvested.connect (this.on_remove_cancelled_harvester);
+ this.harvester_trash.add (harvester);
+ }
+ }
+
private void harvest (File file,
MediaContainer parent = this,
string? flag = null) {
@@ -364,14 +375,8 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
return;
}
- if (this.harvester.contains (file)) {
- debug (_("Already harvesting; cancelling"));
- var harvester = this.harvester[file];
- harvester.harvested.disconnect (this.on_file_harvested);
- harvester.cancellable.cancel ();
- harvester.harvested.connect (this.on_remove_cancelled_harvester);
- this.harvester_trash.add (harvester);
- }
+ // Cancel currently running harvester
+ cancel_harvester (file);
var harvester = new Harvester (parent,
this.media_db,
@@ -411,6 +416,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
var id = Checksum.compute_for_string (ChecksumType.MD5,
file.get_uri ());
+ cancel_harvester (file);
try {
// the full object is fetched instead of simply calling
// exists because we need the parent to signalize the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]