Conserving disk space for a Matrix homeserver is hard, especially if you bridge loads of media. If you decide to go with media retention based on access time, that’s basically non-existent on conduwuit (it only offers remote media deletion atm).

First we need to turn off media checks performed at startup by conduwuit, to avoid access time being updated by checkers:

1
2
prune_missing_media = false
media_startup_check = false

Then, a tmpfiles could go in /usr/lib/tmpfiles.d

1
d	/var/lib/private/<state directory of conduwuit>/media	-	-	-	<retention date>

This setup can purge missing media automatically after a configured period. Though enabling prune_missing_media and media_startup_check may be desired occasionally to remove unwanted media entries in the database.

If you have Mautrix Telegram running, that may cause a bit of problems because the bridge itself does not re-download missing avatars. Manual intervention is required by performing those SQL expressions in the database:

1
2
3
4
5
6
7
UPDATE puppet
SET avatar_set = false;

UPDATE puppet
SET avatar_url = NULL;

TRUNCATE TABLE telegram_file;

Those expressions cause all avatars to be re-downloaded by the bridge and fixes the 404 avatar problem.