From 39fc7f0cf634dce1cc7c642a99e2c8f2b8632dd3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Sep 2009 17:39:50 -0600 Subject: [PATCH] calibredb: Handle the case when the user specifies the same to delete id multiple times --- src/calibre/library/cli.py | 2 +- src/calibre/library/database2.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py index 0a392c1b8c..ea9f8a3f1e 100644 --- a/src/calibre/library/cli.py +++ b/src/calibre/library/cli.py @@ -386,7 +386,7 @@ def command_remove(args, dbpath): else: ids.append(int(y[0])) - do_remove(get_db(dbpath, opts), ids) + do_remove(get_db(dbpath, opts), set(ids)) return 0 diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index cdf1894ab6..79737f4f57 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -921,9 +921,12 @@ class LibraryDatabase2(LibraryDatabase): ''' Removes book from the result cache and the underlying database. ''' - path = os.path.join(self.library_path, self.path(id, index_is_id=True)) + try: + path = os.path.join(self.library_path, self.path(id, index_is_id=True)) + except: + path = None self.data.remove(id) - if os.path.exists(path): + if path and os.path.exists(path): try: winshell.delete_file(path, no_confirm=True, silent=True) except: