mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix problem where the _new_book indication was being lost
This commit is contained in:
parent
0b655b46fa
commit
effa69add2
@ -325,8 +325,9 @@ class KOBO(USBMS):
|
||||
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 @@ class XMLCache(object):
|
||||
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 @@ class BookList(_BookList):
|
||||
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 @@ class USBMS(CLI, Device):
|
||||
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…
x
Reference in New Issue
Block a user