From 1a015a3ba71b7c730aa43feb5937876ade109b2d Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 18 Dec 2020 17:01:52 +0100 Subject: [PATCH] [core] Only attempt to delete untagged files that exist --- legendary/core.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/legendary/core.py b/legendary/core.py index e5314b9..11cf1a7 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -960,11 +960,15 @@ class LegendaryCore: if '' not in tags: tags.append('') - filelist = [i.filename for i in manifest.file_manifest_list.elements if not any( - (fit in i.install_tags) or (not fit and not i.install_tags) for fit in tags - )] - if not delete_filelist(installed_game.install_path, filelist, silent=True): - self.log.debug(f'Deleting some deselected files failed, but that\'s okay.') + # Create list of files that are now no longer needed *and* actually exist on disk + filelist = [ + fm.filename for fm in manifest.file_manifest_list.elements if + not any(((fit in fm.install_tags) or (not fit and not fm.install_tags)) for fit in tags) + and os.path.exists(os.path.join(installed_game.install_path, fm.filename)) + ] + + if not delete_filelist(installed_game.install_path, filelist): + self.log.warning(f'Deleting some deselected files failed, please check/remove manually.') def prereq_installed(self, app_name): igame = self.lgd.get_installed_game(app_name)