Make sure media hashes are not queried until the index is up (#18302)
This commit is contained in:
1
changelog.d/18302.feature
Normal file
1
changelog.d/18302.feature
Normal file
@@ -0,0 +1 @@
|
||||
Hashes of media files are now tracked by Synapse. Media quarantines will now apply to all files with the same hash.
|
||||
@@ -999,6 +999,15 @@ class MediaRepositoryStore(MediaRepositoryBackgroundUpdateStore):
|
||||
None if the media_id doesn't exist.
|
||||
"""
|
||||
|
||||
# If we don't have the index yet, performance tanks, so we return False.
|
||||
# In the background updates, remote_media_cache_sha256_idx is created
|
||||
# after local_media_repository_sha256_idx, which is why we only need to
|
||||
# check for the completion of the former.
|
||||
if not await self.db_pool.updates.has_completed_background_update(
|
||||
"remote_media_cache_sha256_idx"
|
||||
):
|
||||
return False
|
||||
|
||||
def get_matching_media_txn(
|
||||
txn: LoggingTransaction, table: str, sha256: str
|
||||
) -> bool:
|
||||
|
||||
@@ -16,6 +16,13 @@ ALTER TABLE local_media_repository ADD COLUMN sha256 TEXT;
|
||||
ALTER TABLE remote_media_cache ADD COLUMN sha256 TEXT;
|
||||
|
||||
-- Add a background updates to handle creating the new index.
|
||||
INSERT INTO background_updates (ordering, update_name, progress_json) VALUES
|
||||
(9101, 'local_media_repository_sha256_idx', '{}'),
|
||||
(9101, 'remote_media_cache_sha256_idx', '{}');
|
||||
--
|
||||
-- Note that the ordering of the update is not following the usual scheme. This
|
||||
-- is because when upgrading from Synapse 1.127, this index is fairly important
|
||||
-- to have up quickly, so that it doesn't tank performance, which is why it is
|
||||
-- scheduled before other background updates in the 1.127 -> 1.128 upgrade
|
||||
INSERT INTO
|
||||
background_updates (ordering, update_name, progress_json)
|
||||
VALUES
|
||||
(8890, 'local_media_repository_sha256_idx', '{}'),
|
||||
(8891, 'remote_media_cache_sha256_idx', '{}');
|
||||
|
||||
Reference in New Issue
Block a user