File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -587,11 +587,39 @@ impl ModelController {
587587 let response = reqwest:: get ( & logo_url)
588588 . await
589589 . map_err ( |e| crate :: Error :: Error ( format ! ( "Failed to fetch channel logo: {}" , e) ) ) ?;
590+
591+ if !response. status ( ) . is_success ( ) {
592+ return Err ( crate :: Error :: Error ( format ! (
593+ "Failed to fetch channel logo for {}: HTTP {}" ,
594+ channel_id,
595+ response. status( )
596+ ) ) ) ;
597+ }
598+
599+ let content_type = response
600+ . headers ( )
601+ . get ( reqwest:: header:: CONTENT_TYPE )
602+ . and_then ( |v| v. to_str ( ) . ok ( ) )
603+ . unwrap_or ( "" ) ;
604+ if !content_type. is_empty ( ) && !content_type. starts_with ( "image/" ) {
605+ return Err ( crate :: Error :: Error ( format ! (
606+ "Channel logo for {} is not an image: content-type {}" ,
607+ channel_id, content_type
608+ ) ) ) ;
609+ }
610+
590611 let bytes = response
591612 . bytes ( )
592613 . await
593614 . map_err ( |e| crate :: Error :: Error ( format ! ( "Failed to read channel logo bytes: {}" , e) ) ) ?;
594615
616+ if bytes. is_empty ( ) {
617+ return Err ( crate :: Error :: Error ( format ! (
618+ "Channel logo for {} returned empty response" ,
619+ channel_id
620+ ) ) ) ;
621+ }
622+
595623 let reader: AsyncReadPinBox = Box :: pin ( Cursor :: new ( bytes. to_vec ( ) ) ) ;
596624 self . update_channel_image (
597625 library_id,
You can’t perform that action at this time.
0 commit comments