@@ -31,7 +31,7 @@ use ruma::{
3131 } ,
3232 AnyMessageLikeEventContent ,
3333 } ,
34- uint , OwnedMxcUri , OwnedTransactionId , TransactionId , UInt ,
34+ OwnedMxcUri , OwnedTransactionId , TransactionId , UInt ,
3535} ;
3636use tracing:: { debug, error, instrument, trace, warn, Span } ;
3737
@@ -182,23 +182,17 @@ impl RoomSendQueue {
182182
183183 // Process the thumbnail, if it's been provided.
184184 if let Some ( thumbnail) = config. thumbnail . take ( ) {
185- // Create the information required for filling the thumbnail section of the
186- // media event.
187- let ( data, content_type, thumbnail_info) = thumbnail. into_parts ( ) ;
188-
189185 // Normalize information to retrieve the thumbnail in the cache store.
190- let height = thumbnail_info. height . unwrap_or_else ( || {
191- trace ! ( "thumbnail height is unknown, using 0 for the cache entry" ) ;
192- uint ! ( 0 )
193- } ) ;
194- let width = thumbnail_info. width . unwrap_or_else ( || {
195- trace ! ( "thumbnail width is unknown, using 0 for the cache entry" ) ;
196- uint ! ( 0 )
197- } ) ;
186+ let height = thumbnail. height ;
187+ let width = thumbnail. width ;
198188
199189 let txn = TransactionId :: new ( ) ;
200190 trace ! ( upload_thumbnail_txn = %txn, thumbnail_size = ?( height, width) , "attachment has a thumbnail" ) ;
201191
192+ // Create the information required for filling the thumbnail section of the
193+ // media event.
194+ let ( data, content_type, thumbnail_info) = thumbnail. into_parts ( ) ;
195+
202196 // Cache thumbnail in the cache store.
203197 let thumbnail_media_request =
204198 make_local_thumbnail_media_request ( & txn, height, width) ;
@@ -320,27 +314,18 @@ impl QueueStorage {
320314 let from_req =
321315 make_local_thumbnail_media_request ( & info. txn , info. height , info. width ) ;
322316
323- if info. height == uint ! ( 0 ) || info. width == uint ! ( 0 ) {
324- trace ! ( from = ?from_req. source, "removing thumbnail with unknown dimension from cache store" ) ;
325-
326- cache_store
327- . remove_media_content ( & from_req)
328- . await
329- . map_err ( RoomSendQueueStorageError :: EventCacheStoreError ) ?;
330- } else {
331- trace ! ( from = ?from_req. source, to = ?new_source, "renaming thumbnail file key in cache store" ) ;
332-
333- // Reuse the same format for the cached thumbnail with the final MXC ID.
334- let new_format = from_req. format . clone ( ) ;
335-
336- cache_store
337- . replace_media_key (
338- & from_req,
339- & MediaRequestParameters { source : new_source, format : new_format } ,
340- )
341- . await
342- . map_err ( RoomSendQueueStorageError :: EventCacheStoreError ) ?;
343- }
317+ trace ! ( from = ?from_req. source, to = ?new_source, "renaming thumbnail file key in cache store" ) ;
318+
319+ // Reuse the same format for the cached thumbnail with the final MXC ID.
320+ let new_format = from_req. format . clone ( ) ;
321+
322+ cache_store
323+ . replace_media_key (
324+ & from_req,
325+ & MediaRequestParameters { source : new_source, format : new_format } ,
326+ )
327+ . await
328+ . map_err ( RoomSendQueueStorageError :: EventCacheStoreError ) ?;
344329 }
345330 }
346331
0 commit comments