How to properly delete media files #556
|
I sent a message with an attachment. Then I deleted that message. Then I noticed that the file wasn't removed on the server (which is probably a bug?). Then I tried to delete that file: |
Replies: 1 comment 4 replies
|
You're not doing anything wrong, and the part you flagged as "probably a bug" isn't one — in Matrix, redacting a message strips the event's content, but the upload lives in the media store as an independent object with no reference counting back to events. Every homeserver behaves this way, so deleting the message was always going to leave the file behind. Unfortunately it also destroys the only pointer you had, which is exactly why
The command is working correctly; the redacted event genuinely no longer contains a URL to parse. Since the MXC is gone, you need a command that selects by something other than the URL. Looking at the media admin commands, the practical one is Two things to be careful about. It defaults to remote media only, so for your own upload you need the local flag, and it deletes everything in the window — not just your file. So make the window as tight as you can around when you sent the message: The other option, if this is a personal server and you don't mind the collateral, is Going forward the lesson is ordering: run |
That confusing message is an actual bug, not you misreading it. The whole body of
src/admin/media/delete.rsends withErr!("Deleted the MXC from our database and on our filesystem."), so the success text is being returned down the error path, and the admin bot dutifully prefixes it with "Command failed with error:". The file really was deleted, which is why you saw both halves contradict each other. Worth opening as its own issue since it's a one-line fix and completely separate from your original question — anyone deleting media hits it. Your documentation point is fair too, and I'd say it lands harder now that you've confirmed the room is encrypted:delete-by-eventcan only ever work on…