From 81400b56c9fbea19c46d4af61fe7944e5bbe39bb Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 18 Oct 2010 19:39:11 +0100 Subject: [PATCH] Make check_library delete work on linux and mac by checking the file type. --- src/calibre/gui2/dialogs/check_library.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/dialogs/check_library.py b/src/calibre/gui2/dialogs/check_library.py index 741a42893d..f07a25c51a 100644 --- a/src/calibre/gui2/dialogs/check_library.py +++ b/src/calibre/gui2/dialogs/check_library.py @@ -11,7 +11,7 @@ from PyQt4.Qt import QDialog, QVBoxLayout, QHBoxLayout, QTreeWidget, QLabel, \ from calibre.gui2.dialogs.confirm_delete import confirm from calibre.library.check_library import CheckLibrary, CHECKS -from calibre.library.database2 import delete_file +from calibre.library.database2 import delete_file, delete_tree class Item(QTreeWidgetItem): pass @@ -147,7 +147,11 @@ class CheckLibraryDialog(QDialog): for it in items: if it.checkState(1): try: - delete_file(os.path.join(self.db.library_path ,unicode(it.text(1)))) + p = os.path.join(self.db.library_path ,unicode(it.text(1))) + if os.path.isdir(p): + delete_tree(p) + else: + delete_file(p) except: print 'failed to delete', os.path.join(self.db.library_path ,unicode(it.text(1))) self.run_the_check()