diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index c5121e323862..c55d58bdbd49 100644 --- a/synapse/storage/databases/main/media_repository.py +++ b/synapse/storage/databases/main/media_repository.py @@ -150,7 +150,10 @@ def __init__( self._drop_media_index_without_method, ) - self.unused_expiration_time = hs.config.media.unused_expiration_time + if hs.config.media.can_load_media_repo: + self.unused_expiration_time = hs.config.media.unused_expiration_time + else: + self.unused_expiration_time = None async def _drop_media_index_without_method( self, progress: JsonDict, batch_size: int @@ -489,6 +492,7 @@ def get_pending_media_txn(txn: LoggingTransaction) -> Tuple[int, int]: AND created_ts > ? AND media_length IS NULL """ + assert self.unused_expiration_time is not None txn.execute( sql, (