[rygel] server: Unify error handling in ImportResource
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] server: Unify error handling in ImportResource
- Date: Sun, 10 Aug 2014 10:26:47 +0000 (UTC)
commit a78da572d6af848400821995527a0552f573872e
Author: Jens Georg <mail jensge org>
Date: Sun Aug 10 12:22:35 2014 +0200
server: Unify error handling in ImportResource
Signed-off-by: Jens Georg <mail jensge org>
src/librygel-server/rygel-import-resource.vala | 50 +++++++++++++-----------
1 files changed, 27 insertions(+), 23 deletions(-)
---
diff --git a/src/librygel-server/rygel-import-resource.vala b/src/librygel-server/rygel-import-resource.vala
index ea3f4d4..3467dc2 100644
--- a/src/librygel-server/rygel-import-resource.vala
+++ b/src/librygel-server/rygel-import-resource.vala
@@ -204,19 +204,7 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
if (message.status_code >= 200 && message.status_code <= 299) {
this.action.return ();
} else {
- this.status = TransferStatus.ERROR;
- try {
- this.output_stream.close (this.cancellable);
- var file = File.new_for_uri (this.item.get_primary_uri ());
- file.delete (this.cancellable);
- } catch (Error error) {};
-
- var phrase = Status.get_phrase (message.status_code);
- if (message.status_code == 404) {
- this.action.return_error (714, phrase);
- } else {
- this.action.return_error (715, phrase);
- }
+ this.handle_transfer_error (message);
}
this.action = null;
@@ -264,19 +252,35 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
private void finished_cb (Message message) {
if (this.status == TransferStatus.IN_PROGRESS) {
if (!(message.status_code >= 200 && message.status_code <= 299)) {
- this.status = TransferStatus.ERROR;
-
- var phrase = Status.get_phrase (message.status_code);
- warning (_("Failed to import file from %s: %s"),
- this.source_uri,
- phrase);
-
- if (this.action != null) {
- this.action.return_error (714, phrase);
- }
+ this.handle_transfer_error (message);
}
}
this.run_callback ();
}
+
+ private void handle_transfer_error (Message message) {
+ this.status = TransferStatus.ERROR;
+ try {
+ this.output_stream.close (this.cancellable);
+ var file = File.new_for_uri (this.item.get_primary_uri ());
+ file.delete (this.cancellable);
+ } catch (Error error) {};
+
+ var phrase = Status.get_phrase (message.status_code);
+ warning (_("Failed to import file from %s: %s"),
+ this.source_uri,
+ phrase);
+
+ if (action == null) {
+ return;
+ }
+
+ if (message.status_code == Soup.Status.NOT_FOUND ||
+ message.status_code < 100) {
+ this.action.return_error (714, phrase);
+ } else {
+ this.action.return_error (715, phrase);
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]