|
1 | 1 | from .exceptions import ArgumentError, FilesInUseError
|
2 | 2 | from .fsutils import rmtree, unlink
|
3 | 3 | from .installs import get_matching_install_tags
|
4 |
| -from .install_command import update_all_shortcuts |
| 4 | +from .install_command import SHORTCUT_HANDLERS, update_all_shortcuts |
5 | 5 | from .logging import LOGGER
|
6 | 6 | from .pathutils import PurePath
|
7 | 7 | from .tagutils import tag_or_range
|
8 | 8 |
|
9 | 9 |
|
10 | 10 | def _iterdir(p, only_files=False):
|
11 | 11 | try:
|
| 12 | + if only_files: |
| 13 | + return [f for f in p.iterdir() if p.is_file()] |
12 | 14 | return list(p.iterdir())
|
13 | 15 | except FileNotFoundError:
|
14 | 16 | LOGGER.debug("Skipping %s because it does not exist", p)
|
@@ -42,18 +44,15 @@ def execute(cmd):
|
42 | 44 | LOGGER.warn("Unable to purge %s because it is still in use.",
|
43 | 45 | i["display-name"])
|
44 | 46 | continue
|
45 |
| - LOGGER.info("Purging saved downloads") |
46 |
| - for f in _iterdir(cmd.install_dir): |
47 |
| - LOGGER.debug("Purging %s", f) |
48 |
| - try: |
49 |
| - rmtree(f, after_5s_warning=warn_msg.format("cached downloads"), |
50 |
| - remove_ext_first=("exe", "dll", "json")) |
51 |
| - except FilesInUseError: |
52 |
| - pass |
53 |
| - LOGGER.info("Purging global commands") |
| 47 | + LOGGER.info("Purging saved downloads from %s", cmd.download_dir) |
| 48 | + rmtree(cmd.download_dir, after_5s_warning=warn_msg.format("cached downloads")) |
| 49 | + LOGGER.info("Purging global commands from %s", cmd.global_dir) |
54 | 50 | for f in _iterdir(cmd.global_dir):
|
55 | 51 | LOGGER.debug("Purging %s", f)
|
56 | 52 | rmtree(f, after_5s_warning=warn_msg.format("global commands"))
|
| 53 | + LOGGER.info("Purging all shortcuts") |
| 54 | + for _, cleanup in SHORTCUT_HANDLERS.values(): |
| 55 | + cleanup(cmd, []) |
57 | 56 | LOGGER.debug("END uninstall_command.execute")
|
58 | 57 | return
|
59 | 58 |
|
|
0 commit comments