Skip to content

Commit 1a015a3

Browse files
committed
[core] Only attempt to delete untagged files that exist
1 parent f42d637 commit 1a015a3

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

legendary/core.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,15 @@ def uninstall_tag(self, installed_game: InstalledGame):
960960
if '' not in tags:
961961
tags.append('')
962962

963-
filelist = [i.filename for i in manifest.file_manifest_list.elements if not any(
964-
(fit in i.install_tags) or (not fit and not i.install_tags) for fit in tags
965-
)]
966-
if not delete_filelist(installed_game.install_path, filelist, silent=True):
967-
self.log.debug(f'Deleting some deselected files failed, but that\'s okay.')
963+
# Create list of files that are now no longer needed *and* actually exist on disk
964+
filelist = [
965+
fm.filename for fm in manifest.file_manifest_list.elements if
966+
not any(((fit in fm.install_tags) or (not fit and not fm.install_tags)) for fit in tags)
967+
and os.path.exists(os.path.join(installed_game.install_path, fm.filename))
968+
]
969+
970+
if not delete_filelist(installed_game.install_path, filelist):
971+
self.log.warning(f'Deleting some deselected files failed, please check/remove manually.')
968972

969973
def prereq_installed(self, app_name):
970974
igame = self.lgd.get_installed_game(app_name)

0 commit comments

Comments
 (0)