[rygel] core: Don't allow uploading to non-place-holder items



commit 9c65a6ae6cf022292f2a068839fe507ac1946539
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 26 02:39:49 2010 +0300

    core: Don't allow uploading to non-place-holder items
    
    ImportResource and HTTP POST now error out on requests for
    non-place-holder items.

 src/rygel/rygel-http-post.vala       |    6 ++++++
 src/rygel/rygel-import-resource.vala |   15 +++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-http-post.vala b/src/rygel/rygel-http-post.vala
index 71b67eb..9293a42 100644
--- a/src/rygel/rygel-http-post.vala
+++ b/src/rygel/rygel-http-post.vala
@@ -44,6 +44,12 @@ internal class Rygel.HTTPPost : HTTPRequest {
         this.msg.got_chunk.connect (this.on_got_chunk);
         this.msg.got_body.connect (this.on_got_body);
 
+        if (!this.item.place_holder) {
+            var msg = _("Pushing data to non-empty item '%s' not allowed");
+
+            throw new ContentDirectoryError.INVALID_ARGS (msg, this.item.id);
+        }
+
         this.file = yield this.item.get_writable (this.cancellable);
         if (this.file == null) {
             throw new HTTPRequestError.BAD_REQUEST (
diff --git a/src/rygel/rygel-import-resource.vala b/src/rygel/rygel-import-resource.vala
index 9b5543e..279b333 100644
--- a/src/rygel/rygel-import-resource.vala
+++ b/src/rygel/rygel-import-resource.vala
@@ -109,7 +109,14 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
                      this.destination_uri,
                      error.message);
 
-            this.action.return_error (719, error.message);
+            int code;
+            if (error is ContentDirectoryError) {
+                code = error.code;
+            } else {
+                code = 719;
+            }
+
+            this.action.return_error (code, error.message);
             this.status = TransferStatus.ERROR;
             this.completed ();
 
@@ -152,8 +159,12 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
             !(media_object is MediaItem) ||
             media_object.uris.size < 1) {
             return this.destination_uri;
-        } else {
+        } else if ((media_object as MediaItem).place_holder) {
             return media_object.uris[0];
+        } else {
+            var msg = _("Pushing data to non-empty item '%s' not allowed");
+
+            throw new ContentDirectoryError.INVALID_ARGS (msg, media_object.id);
         }
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]