Deleting an activity with attachments doesn't delete the file or entries in civicrm_file/civicrm_entity_file
This might be an old issue but I did a quick look and didn't see anything. If a file is shared between two entities, then I could understand if it leaves civicrm_file and the file itself and just removes civicrm_entity_file, but it doesn't seem to remove anything, and even when there's no sharing (i.e. zero reference count).
- Create e.g. an email activity. Add an attachment.
- Delete the activity, e.g. from your contact's activity tab.
- Look in sites/default/files/civicrm/custom. The attachment file is still there.
- Also the entries are still there in civicrm_file and civicrm_entity_file even though the entry in civicrm_activity isn't there anymore.