Skip to content

Commit

Permalink
on_actionRemove: properly remove item from list
Browse files Browse the repository at this point in the history
  • Loading branch information
bicobus committed Feb 10, 2020
1 parent f0d9f58 commit 4bf11a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 7 additions & 9 deletions qmm/filehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def uninstall_files(file_list: list):
else:
dlist.append(file)

dlist.sort(reverse=True)
dlist.sort(reverse=True) # list of strings, longest first
for directory in dlist:
try:
directory.rmdir()
Expand All @@ -573,13 +573,11 @@ def delete_archive(filepath):
if not isinstance(filepath, pathlib.Path):
filepath = pathlib.Path(settings['local_repository'], filepath)

if filepath.exists():
try:
filepath.unlink()
except OSError as e:
logger.debug(filepath)
logger.error("Unable to remove file from drive: %s", e)
return False
try:
filepath.unlink()
except OSError as e:
logger.error("Unable to remove file %s from drive: %s", filepath, e)
return False
else:
logger.error("Unable to remove an non-existing file: %s", filepath)
logger.info("Deleted file %s", filepath.as_posix())
return True
2 changes: 2 additions & 0 deletions qmm/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def _do_delete_selected_file(self, menu_item=None):
return
filehandler.delete_archive(item.filename)
del self.managed_archives[item.filename]
self.listWidget.takeItem(self.listWidget.row(item))
del item
filehandler.detect_conflicts_between_archives(self.managed_archives)

@pyqtSlot(name="on_actionInstall_Mod_triggered")
Expand Down

0 comments on commit 4bf11a1

Please sign in to comment.