Fix unreachable call to notify() when adding formats with the legacy API

This commit is contained in:
Kovid Goyal 2016-06-24 13:22:51 +05:30
parent d8431538a1
commit 7761f537e6

View File

@ -275,22 +275,16 @@ class LibraryDatabase(object):
def add_format(self, index, fmt, stream, index_is_id=False, path=None, notify=True, replace=True, copy_function=None): def add_format(self, index, fmt, stream, index_is_id=False, path=None, notify=True, replace=True, copy_function=None):
''' path and copy_function are ignored by the new API ''' ''' path and copy_function are ignored by the new API '''
book_id = index if index_is_id else self.id(index) book_id = index if index_is_id else self.id(index)
try: ret = self.new_api.add_format(book_id, fmt, stream, replace=replace, run_hooks=False, dbapi=self)
return self.new_api.add_format(book_id, fmt, stream, replace=replace, run_hooks=False, dbapi=self) self.notify('metadata', [book_id])
except: return ret
raise
else:
self.notify('metadata', [book_id])
def add_format_with_hooks(self, index, fmt, fpath, index_is_id=False, path=None, notify=True, replace=True): def add_format_with_hooks(self, index, fmt, fpath, index_is_id=False, path=None, notify=True, replace=True):
''' path is ignored by the new API ''' ''' path is ignored by the new API '''
book_id = index if index_is_id else self.id(index) book_id = index if index_is_id else self.id(index)
try: ret = self.new_api.add_format(book_id, fmt, fpath, replace=replace, run_hooks=True, dbapi=self)
return self.new_api.add_format(book_id, fmt, fpath, replace=replace, run_hooks=True, dbapi=self) self.notify('metadata', [book_id])
except: return ret
raise
else:
self.notify('metadata', [book_id])
# }}} # }}}