Fully deleting datablocks from a blend file doesn't happen as easily as most users might expect, since "delete" is often used in the UI when "un-link" is what is actually meant. This can cause a lot of confusion and uncertainty during production. Proper deletion of datablocks requires that they are first un-linked, then they can be purged via File->Clean Up->Recursive Unused Datablocks. This works beautifully, and I would like to propose adding an option to have this operation executed after existing deletion operators. For example, after deleting a collection of objects, it would then also delete everything that was used only by those objects, such as their mesh and shape key datablocks, materials, actions, textures, etc.
My previous proposal was to have an option to execute Recursive Purge only on file save, which seemed to make sense to everyone I talked to at the time. (@sybren @mont29 @Severin @simonthommes )
I still think that solution would be a step forward, but the new proposal above would achieve the same goals in an even more foolproof way.
### Use case
Currently, this can very easily happen:
- Animator duplicates an overridden character. All its objects get a .001 suffix.
- Animator deletes that copy, saves their file, and later re-opens it. Only one "layer" of unused objects has been cleaned, so there can still be orphan object datablocks lying around unseen.
- Animator duplicates the character again. Now the number suffix of their objects are all over the place. Some of them have .001 and others have .002.
As they continue working and duplicating characters, the old, unused objects slowly get deleted, and the name suffixes really get all over the place. It's not nice to get your objects names all mixed up like this, as things get really confusing when trying to troubleshoot problems in a production file, since everywhere where one object references another, the mismatching suffixes give the troubleshooter anxiety and uncertainty. The only way to avoid this currently is to tell the entire production team to always run a recursive Purge after deleting anything, which is very error-prone.
### Potential issues
- ~~The current recursive purge purges Text datablocks, which is bad because they don't have the possibility of a "Fake User", so they should be excluded (or better yet, be included in the "fake user" system, and get a fake user by default). ~~ (Fixed by D10983)
- Actions don't have fake user enabled by default. The long standing issue of Action datablocks "disappearing" on users and making them lose hours of work if they forget to click Fake User would be exacerbated by this change. This could be trivially fixed by giving Actions a fake user on creation, and forcing users to clean up their unused Actions themselves.