Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Prevent local quarantined media from being claimed by media retention #12972

Merged
merged 11 commits into from
Jun 7, 2022
Merged
1 change: 1 addition & 0 deletions synapse/rest/media/v1/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ async def delete_old_local_media(
keep_profiles: Switch to delete also files that are still used in image data
(e.g user profile, room avatar). If false these files will be deleted.
delete_quarantined_media: If True, media marked as quarantined will be deleted.
delete_protected_media: If True, media marked as protected will be deleted.

Returns:
A tuple of (list of deleted media IDs, total deleted media IDs).
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ async def get_local_media_ids(
if include_protected_media is False:
# Do not include media that has been protected from quarantine
sql += """
AND safe_from_quarantine = 0
AND safe_from_quarantine = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail on old sqlite

try AND NOT safe_from_quarantine

And read https://matrix-org.github.io/synapse/latest/development/database_schema.html#boolean-columns

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. Thanks for catching! Fixed in #12977.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a minimum supported sqlite version? Should CI have caught this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our deprecation policy only mentions Python and PostgreSQL. Our unit tests look to only test different postgres versions as well.

I'm not sure if we do have a minimum supported version of SQLite, but https://matrix-org.github.io/synapse/latest/development/database_schema.html?highlight=database#boolean-columns does mention older versions, and it may be good to test an older SQLite in CI (maybe similar mistakes have slipped in already and we don't even know!).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought at least one of our CI runs did old SQLite by using an old version of ubuntu? Though it does look like our CI is using latest ubuntu images everywhere...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's take this to #12983

"""

def _get_local_media_ids_txn(txn: LoggingTransaction) -> List[str]:
Expand Down