From 748eb921c5294e5f3a2558f968d7684fed0e1d5c Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sat, 27 Jul 2013 10:32:49 +0200 Subject: [PATCH 1/2] Prevent exception when deleting a non-existent book. --- src/calibre/library/caches.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index e552ead591..022ba9402e 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -920,7 +920,8 @@ class ResultCache(SearchQueryParser): # {{{ def remove(self, id): try: - self._uuid_map.pop(self._data[id][self._uuid_column_index], None) + if self._data[id] is not None: + self._uuid_map.pop(self._data[id][self._uuid_column_index], None) except IndexError: pass # id is out of bounds -- no uuid in the map to remove try: From d47603bdacfe7fc92b552de59e763b52ef800cb8 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sat, 27 Jul 2013 10:33:14 +0200 Subject: [PATCH 2/2] Allow an empty field specifier in calibredb, permitting one to get a list of ids --- src/calibre/library/cli.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py index 012d88dace..a6ecca3721 100644 --- a/src/calibre/library/cli.py +++ b/src/calibre/library/cli.py @@ -199,15 +199,18 @@ def command_list(args, dbpath): afields.add('*'+f) if data['datatype'] == 'series': afields.add('*'+f+'_index') - fields = [str(f.strip().lower()) for f in opts.fields.split(',')] - if 'all' in fields: - fields = sorted(list(afields)) - if not set(fields).issubset(afields): - parser.print_help() - print - prints(_('Invalid fields. Available fields:'), - ','.join(sorted(afields)), file=sys.stderr) - return 1 + if opts.fields.strip(): + fields = [str(f.strip().lower()) for f in opts.fields.split(',')] + if 'all' in fields: + fields = sorted(list(afields)) + if not set(fields).issubset(afields): + parser.print_help() + print + prints(_('Invalid fields. Available fields:'), + ','.join(sorted(afields)), file=sys.stderr) + return 1 + else: + fields = [] if not opts.sort_by in afields and opts.sort_by is not None: parser.print_help()