@@ -285,18 +285,27 @@ def update_socket_images(conn):
285285 for row in conn .execute (q_iter ):
286286 img_key = f'{ row .public_key } /{ row .id } .jpg'
287287 r = session .get (f'{ base_url } /{ img_key } ' )
288- r .raise_for_status ()
289- with BytesIO () as temp_file :
290- temp_file .write (r .content )
291- temp_file .seek (0 )
292- s3_client .upload_fileobj (Fileobj = temp_file , Bucket = settings .aws_bucket_name , Key = img_key )
293- print (f'Uploading image { img_key } ' )
288+ if r .status_code == 200 :
289+ with BytesIO () as temp_file :
290+ temp_file .write (r .content )
291+ temp_file .seek (0 )
292+ s3_client .upload_fileobj (Fileobj = temp_file , Bucket = settings .aws_bucket_name , Key = img_key )
293+ print (f'Uploading image { img_key } ' )
294+ elif r .status_code == 404 :
295+ print (f'Unable to find { img_key } , returned 404' )
296+ else :
297+ r .raise_for_status ()
294298
295299 img_thumb_key = f'{ row .public_key } /{ row .id } .thumb.jpg'
296300 r = session .get (f'{ base_url } /{ img_thumb_key } ' )
297301 r .raise_for_status ()
298- with BytesIO () as temp_file :
299- temp_file .write (r .content )
300- temp_file .seek (0 )
301- s3_client .upload_fileobj (Fileobj = temp_file , Bucket = settings .aws_bucket_name , Key = img_thumb_key )
302- print (f'Uploading image { img_thumb_key } ' )
302+ if r .status_code == 200 :
303+ with BytesIO () as temp_file :
304+ temp_file .write (r .content )
305+ temp_file .seek (0 )
306+ s3_client .upload_fileobj (Fileobj = temp_file , Bucket = settings .aws_bucket_name , Key = img_thumb_key )
307+ print (f'Uploading image { img_thumb_key } ' )
308+ elif r .status_code == 404 :
309+ print (f'Unable to find { img_key } , returned 404' )
310+ else :
311+ r .raise_for_status ()
0 commit comments