mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-19 17:43:17 +02:00
Fix problem where the _new_book indication was being lost
This commit is contained in:
parent
0b655b46fa
commit
effa69add2
4 changed files with 14 additions and 7 deletions
|
|
@ -325,8 +325,9 @@ def add_books_to_metadata(self, locations, metadata, booklists):
|
|||
book = Book(prefix, lpath, '', '', '', '', '', '', other=info)
|
||||
if book.size is None:
|
||||
book.size = os.stat(self.normalize_path(path)).st_size
|
||||
book._new_book = True # Must be before add_book
|
||||
booklists[blist].add_book(book, replace_metadata=True)
|
||||
b = booklists[blist].add_book(book, replace_metadata=True)
|
||||
if b:
|
||||
b._new_book = True
|
||||
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
||||
|
||||
def contentid_from_path(self, path, ContentType):
|
||||
|
|
|
|||
|
|
@ -362,6 +362,7 @@ def update(self, booklists, collections_attributes, plugboard):
|
|||
if plugboard is not None:
|
||||
newmi = book.deepcopy_metadata()
|
||||
newmi.template_to_attribute(book, plugboard)
|
||||
newmi.set('_new_book', getattr(book, '_new_book', False))
|
||||
else:
|
||||
newmi = book
|
||||
(gtz_count, ltz_count, use_tz_var) = \
|
||||
|
|
|
|||
|
|
@ -71,17 +71,21 @@ def supports_collections(self):
|
|||
return False
|
||||
|
||||
def add_book(self, book, replace_metadata):
|
||||
'''
|
||||
Add the book to the booklist, if needed. Return None if the book is
|
||||
already there and not updated, otherwise return the book.
|
||||
'''
|
||||
try:
|
||||
b = self.index(book)
|
||||
except (ValueError, IndexError):
|
||||
b = None
|
||||
if b is None:
|
||||
self.append(book)
|
||||
return True
|
||||
return book
|
||||
if replace_metadata:
|
||||
self[b].smart_update(book, replace_metadata=True)
|
||||
return True
|
||||
return False
|
||||
return self[b]
|
||||
return None
|
||||
|
||||
def remove_book(self, book):
|
||||
self.remove(book)
|
||||
|
|
|
|||
|
|
@ -242,8 +242,9 @@ def add_books_to_metadata(self, locations, metadata, booklists):
|
|||
book = self.book_class(prefix, lpath, other=info)
|
||||
if book.size is None:
|
||||
book.size = os.stat(self.normalize_path(path)).st_size
|
||||
book._new_book = True # Must be before add_book
|
||||
booklists[blist].add_book(book, replace_metadata=True)
|
||||
b = booklists[blist].add_book(book, replace_metadata=True)
|
||||
if b:
|
||||
b._new_book = True
|
||||
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
||||
debug_print('USBMS: finished adding metadata')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue