Skip to content

Prune Messages deletes files of messages it doesn't prune #42591

Description

@mandar1045

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions