This commit is contained in:
Kovid Goyal 2013-07-12 11:10:35 +05:30
parent 4a2a4a54d4
commit 6a724d931f

View File

@ -217,12 +217,22 @@ 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.data.index_to_id(index) book_id = index if index_is_id else self.data.index_to_id(index)
return self.new_api.add_format(book_id, fmt, stream, replace=replace, run_hooks=False, dbapi=self) try:
return self.new_api.add_format(book_id, fmt, stream, replace=replace, run_hooks=False, dbapi=self)
except:
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.data.index_to_id(index) book_id = index if index_is_id else self.data.index_to_id(index)
return self.new_api.add_format(book_id, fmt, fpath, replace=replace, run_hooks=True, dbapi=self) try:
return self.new_api.add_format(book_id, fmt, fpath, replace=replace, run_hooks=True, dbapi=self)
except:
raise
else:
self.notify('metadata', [book_id])
# }}} # }}}