this woulld be hard unless if they have one specific addon folder but some addon use styles, src, data, and so on and let say themehouse and XFA that have addons depending on each other it would be a disaster if you removed those files
I don`t think it will be a good idea to do it automatically. Will be nice if we can have a popup notice, when you uninstall an add-on, who tell you the directories of that add-on location and, if the add-on have common files or not.
I agree, uninstalling and removing files should be done with care and not by some automated process. Maybe once an addon is uninstalled, and admins have verified everything is functioning correctly, then have a button to click to remove the files.
Have you seen...? Obviously not I'm only telling you now. This has been implemented in XF 2.2.7!
Installable add-ons (add-ons that are not installed / have been uninstalled) may now contain a "Delete files" button (with some exceptions).
Clicking "Delete files" enumerates the add-on's hashes.json file to work out which files belong to that add-on. It checks if they are deletable and lists the files that would be deleted if you proceed:
Clicking "Delete files" triggers a job which deletes those files and the add-on's directory.
No other directories are removed (this is by design to reduce the risk of other add-ons being affected) so this will leave empty directories on your server but once complete the add-on will no longer appear in the "Installable add-ons" list.
In some cases, you may come across an add-on that shares files with another add-on. This is less common (many add-ons by @Xon used to do this but not so much now) but theoretically could be used for nefarious means - for example a specially crafted hashes.json file might make it seem like another add-ons files belong to that add-on or even a core XF file.
So we flag it if an add-on you're deleting contains files that may be in use by another add-on:
Rather than blocking the deletion entirely, we simply ensure those files are skipped.
There are some situations where the "Delete files" button will not be available in the add-on list, particularly if the src/addons directory is not writable (this means the files within would not be deletable) or if the add-on contains files in an _output directory (used during development).