From bf4291496c458a3a5e7db98ade76f54580b92baf Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Tue, 28 May 2024 11:39:26 -0700 Subject: [PATCH] Check if menu location exists before iterating --- menuinst/platforms/win.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/menuinst/platforms/win.py b/menuinst/platforms/win.py index 84412a39..97ea56d7 100644 --- a/menuinst/platforms/win.py +++ b/menuinst/platforms/win.py @@ -38,7 +38,9 @@ def create(self) -> Tuple[os.PathLike]: def remove(self) -> Tuple[os.PathLike]: # Only remove if the Start Menu directory is empty in case applications share a folder. try: - next(Path(self.start_menu_location).iterdir()) + menu_location = Path(self.start_menu_location) + if menu_location.exists(): + next(menu_location.iterdir()) except StopIteration: log.debug("Removing %s", self.start_menu_location) shutil.rmtree(self.start_menu_location, ignore_errors=True)