diff options
author | Slavi Pantaleev <slavi@devture.com> | 2017-11-04 09:47:25 +0200 |
---|---|---|
committer | Slavi Pantaleev <slavi@devture.com> | 2017-11-04 09:50:15 +0200 |
commit | 805196fbeb396623b30a6d748863046377223af6 (patch) | |
tree | 1e6db5706d4083fd3ff62693c30a98b67bb4f75d /synapse/storage | |
parent | Merge pull request #2630 from matrix-org/luke/fix-rooms-in-group (diff) | |
download | synapse-805196fbeb396623b30a6d748863046377223af6.tar.xz |
Avoid no-op media deletes
If there are no media entries to delete, avoid creating transactions, prepared statements and unnecessary log entries. Signed-off-by: Slavi Pantaleev <slavi@devture.com>
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/media_repository.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/storage/media_repository.py b/synapse/storage/media_repository.py index 7110a71279..52e5cdad70 100644 --- a/synapse/storage/media_repository.py +++ b/synapse/storage/media_repository.py @@ -254,6 +254,9 @@ class MediaRepositoryStore(SQLBaseStore): return self.runInteraction("get_expired_url_cache", _get_expired_url_cache_txn) def delete_url_cache(self, media_ids): + if len(media_ids) == 0: + return + sql = ( "DELETE FROM local_media_repository_url_cache" " WHERE media_id = ?" @@ -281,6 +284,9 @@ class MediaRepositoryStore(SQLBaseStore): ) def delete_url_cache_media(self, media_ids): + if len(media_ids) == 0: + return + def _delete_url_cache_media_txn(txn): sql = ( "DELETE FROM local_media_repository" |