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)
|
book = Book(prefix, lpath, '', '', '', '', '', '', other=info)
|
||||||
if book.size is None:
|
if book.size is None:
|
||||||
book.size = os.stat(self.normalize_path(path)).st_size
|
book.size = os.stat(self.normalize_path(path)).st_size
|
||||||
book._new_book = True # Must be before add_book
|
b = booklists[blist].add_book(book, replace_metadata=True)
|
||||||
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...'))
|
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
||||||
|
|
||||||
def contentid_from_path(self, path, ContentType):
|
def contentid_from_path(self, path, ContentType):
|
||||||
|
@ -362,6 +362,7 @@ class XMLCache(object):
|
|||||||
if plugboard is not None:
|
if plugboard is not None:
|
||||||
newmi = book.deepcopy_metadata()
|
newmi = book.deepcopy_metadata()
|
||||||
newmi.template_to_attribute(book, plugboard)
|
newmi.template_to_attribute(book, plugboard)
|
||||||
|
newmi.set('_new_book', getattr(book, '_new_book', False))
|
||||||
else:
|
else:
|
||||||
newmi = book
|
newmi = book
|
||||||
(gtz_count, ltz_count, use_tz_var) = \
|
(gtz_count, ltz_count, use_tz_var) = \
|
||||||
|
@ -71,17 +71,21 @@ class BookList(_BookList):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def add_book(self, book, replace_metadata):
|
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:
|
try:
|
||||||
b = self.index(book)
|
b = self.index(book)
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
b = None
|
b = None
|
||||||
if b is None:
|
if b is None:
|
||||||
self.append(book)
|
self.append(book)
|
||||||
return True
|
return book
|
||||||
if replace_metadata:
|
if replace_metadata:
|
||||||
self[b].smart_update(book, replace_metadata=True)
|
self[b].smart_update(book, replace_metadata=True)
|
||||||
return True
|
return self[b]
|
||||||
return False
|
return None
|
||||||
|
|
||||||
def remove_book(self, book):
|
def remove_book(self, book):
|
||||||
self.remove(book)
|
self.remove(book)
|
||||||
|
@ -242,8 +242,9 @@ class USBMS(CLI, Device):
|
|||||||
book = self.book_class(prefix, lpath, other=info)
|
book = self.book_class(prefix, lpath, other=info)
|
||||||
if book.size is None:
|
if book.size is None:
|
||||||
book.size = os.stat(self.normalize_path(path)).st_size
|
book.size = os.stat(self.normalize_path(path)).st_size
|
||||||
book._new_book = True # Must be before add_book
|
b = booklists[blist].add_book(book, replace_metadata=True)
|
||||||
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...'))
|
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
||||||
debug_print('USBMS: finished adding metadata')
|
debug_print('USBMS: finished adding metadata')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user