Skip to content

Commit

Permalink
Update menuinst/platforms/win.py
Browse files Browse the repository at this point in the history
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
  • Loading branch information
marcoesters and jaimergp authored Jun 5, 2024
1 parent bf42914 commit 707e3df
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions menuinst/platforms/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ 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:
menu_location = Path(self.start_menu_location)
if menu_location.exists():
menu_location = Path(self.start_menu_location)
if menu_location.exists():
try:
# Check directory contents. If empty, it will raise StopIteration
# and only in that case we delete the directory.
next(menu_location.iterdir())
except StopIteration:
log.debug("Removing %s", self.start_menu_location)
shutil.rmtree(self.start_menu_location, ignore_errors=True)
except StopIteration:
log.debug("Removing %s", self.start_menu_location)
shutil.rmtree(self.start_menu_location, ignore_errors=True)
return (self.start_menu_location,)

@property
Expand Down

0 comments on commit 707e3df

Please sign in to comment.