Fix: Uninstall registry pointed non-exists directory (#88)

This commit is contained in:
LmeSzinc 2023-09-13 02:22:43 +08:00
parent 13c7e541f0
commit 29568c770c
3 changed files with 10 additions and 10 deletions

View File

@ -197,10 +197,7 @@ class EmulatorBase:
list[str]:
"""
folder = self.abspath(folder)
try:
return list(iter_folder(folder, is_dir=is_dir, ext=ext))
except FileNotFoundError:
return []
return list(iter_folder(folder, is_dir=is_dir, ext=ext))
class EmulatorManagerBase:

View File

@ -476,11 +476,9 @@ class EmulatorManager(EmulatorManagerBase):
if Emulator.is_emulator(file) and os.path.exists(file):
exe.add(file)
# MuMu specific directory
folder = abspath(os.path.join(os.path.dirname(uninstall), 'EmulatorShell'))
if os.path.exists(folder):
for file in iter_folder(folder, ext='.exe'):
if Emulator.is_emulator(file) and os.path.exists(file):
exe.add(file)
for file in iter_folder(abspath(os.path.join(os.path.dirname(uninstall), 'EmulatorShell')), ext='.exe'):
if Emulator.is_emulator(file) and os.path.exists(file):
exe.add(file)
exe = [Emulator(path).path for path in exe if Emulator.is_emulator(path)]
exe = sorted(set(exe))

View File

@ -35,7 +35,12 @@ def iter_folder(folder, is_dir=False, ext=None):
Yields:
str: Absolute path of files
"""
for file in os.listdir(folder):
try:
files = os.listdir(folder)
except FileNotFoundError:
return
for file in files:
sub = os.path.join(folder, file)
if is_dir:
if os.path.isdir(sub):