Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

RunPendingUninstalls not cleaning up empty directories #56

Open
pushedx opened this issue Mar 23, 2017 · 0 comments
Open

RunPendingUninstalls not cleaning up empty directories #56

pushedx opened this issue Mar 23, 2017 · 0 comments

Comments

@pushedx
Copy link

pushedx commented Mar 23, 2017

In situations where addins are frequently added, removed, and updated, the addins directory tends to fill up with empty directories between application restarts rather quickly. Each one of these directories is then scanned on Registry.Update, potentially causing slowdowns once a lot of them exist.

Perhaps AddinDatabase.RunPendingUninstalls can try deleting the containing folder the addin file being removed was stored in, keeping things a lot more tidy for end users, and avoiding a massive directory of empty folders.

Something as simple as:

if (canUninstall) {
	foreach (string file in adn.Files.OrderByDescending(s => s).ToList()) {
		var dir = Path.GetDirectoryName(file);
		if (dir != null) {
			try {
				Directory.Delete(dir);
			}
			catch {
			}
		}
	}
	Configuration.UnregisterForUninstall (adn.AddinId);
	changesDone = true;
}

to replace the previous code of:

if (canUninstall) {
	Configuration.UnregisterForUninstall (adn.AddinId);
	changesDone = true;
}

Seems to do the trick, but I'm not sure if that code is compatible with all the targets of Mono.Addins, so just throwing out an example.

I'm not familiar with the possible directory structure for multi-assembly addins, but in my simple testing I just had a single file in a directory so it worked as intended. Maybe a recursive delete can be done regardless if the directory is empty or not, but I'm not sure of the implications of that, or if that's even desirable. I can't think of any case where empty directories of uninstalled addins are desirable though!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant