When you prune with a limit (the Prune Messages panel always sends 2000), files get deleted for messages that aren't actually pruned.
To reproduce: post 25 messages in a channel with every 5th one being a file (F1–F5), then call rooms.cleanHistory with limit: 10. F1 and F2 get deleted as expected, but F3–F5 are still in the room and their downloads now return 404.
Looks like the limit is applied to two different queries: the file cleanup takes the first N messages that have files (L60), while the delete takes the first N messages of any type (L147). Picking the message ids first and only removing files for those should fix it. Happy to send a PR.
Tested on 8.10.0-develop (83d0fc2), Docker.
When you prune with a limit (the Prune Messages panel always sends 2000), files get deleted for messages that aren't actually pruned.
To reproduce: post 25 messages in a channel with every 5th one being a file (F1–F5), then call
rooms.cleanHistorywithlimit: 10. F1 and F2 get deleted as expected, but F3–F5 are still in the room and their downloads now return 404.Looks like the limit is applied to two different queries: the file cleanup takes the first N messages that have files (L60), while the delete takes the first N messages of any type (L147). Picking the message ids first and only removing files for those should fix it. Happy to send a PR.
Tested on 8.10.0-develop (83d0fc2), Docker.