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

Fix empty url_cache_thumbnails/yyyy-mm-dd/ directories being left behind #10924

Merged
merged 6 commits into from
Sep 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extract 2 day expiry threshold into a constant
  • Loading branch information
Sean Quah committed Sep 27, 2021
commit ed23655a3d2c25feecad5974be5f70bf328226f3
3 changes: 2 additions & 1 deletion synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

ONE_HOUR = 60 * 60 * 1000
ONE_DAY = 24 * ONE_HOUR
IMAGE_CACHE_EXPIRY_MS = 2 * ONE_DAY


@attr.s(slots=True, frozen=True, auto_attribs=True)
Expand Down Expand Up @@ -529,7 +530,7 @@ async def _expire_url_cache_data(self) -> None:
# These may be cached for a bit on the client (i.e., they
# may have a room open with a preview url thing open).
# So we wait a couple of days before deleting, just in case.
expire_before = now - 2 * ONE_DAY
expire_before = now - IMAGE_CACHE_EXPIRY_MS
media_ids = await self.store.get_url_cache_media_before(expire_before)

removed_media = []
Expand Down