core: Return 404 on missing thumbnail
authorJens Georg <mail@jensge.org>
Thu, 15 Mar 2012 07:56:59 +0000 (08:56 +0100)
committerJens Georg <mail@jensge.org>
Thu, 15 Mar 2012 08:04:32 +0000 (09:04 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=672048

src/rygel/rygel-http-get.vala

index a7ca2ef..c98d56c 100644 (file)
@@ -90,31 +90,36 @@ internal class Rygel.HTTPGet : HTTPRequest {
         if (this.uri.thumbnail_index >= 0) {
             if (this.item is MusicItem) {
                 var music = this.item as MusicItem;
-
                 this.thumbnail = music.album_art;
+
+                return;
             } else if (this.item is VisualItem) {
                 var visual = this.item as VisualItem;
-                if (visual.thumbnails.size >= this.uri.thumbnail_index) {
+                if (this.uri.thumbnail_index < visual.thumbnails.size) {
                     this.thumbnail = visual.thumbnails.get
                                             (this.uri.thumbnail_index);
+
+                    return;
                 }
-            } else {
-                throw new HTTPRequestError.NOT_FOUND
-                                        ("No Thumbnail available for item '%s",
-                                         this.item.id);
             }
-        } else if (this.uri.subtitle_index >= 0) {
-            if (!(this.item is VideoItem)) {
-                throw new HTTPRequestError.NOT_FOUND
-                                        ("No subtitles available for item '%s",
+
+            throw new HTTPRequestError.NOT_FOUND
+                                        ("No Thumbnail available for item '%s",
                                          this.item.id);
-            }
+        }
 
+        if (this.uri.subtitle_index >= 0 && this.item is VideoItem) {
             var video = this.item as VideoItem;
 
-            if (this.uri.subtitle_index <= video.subtitles.size) {
+            if (this.uri.subtitle_index < video.subtitles.size) {
                 this.subtitle = video.subtitles.get (this.uri.subtitle_index);
+
+                return;
             }
+
+            throw new HTTPRequestError.NOT_FOUND
+                                        ("No subtitles available for item '%s",
+                                         this.item.id);
         }
     }