mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
8b0ae7bde2
@ -426,10 +426,7 @@ class WritingTest(BaseTest):
|
|||||||
self.compare_metadata(nmi, oldmi, exclude={'last_modified', 'format_metadata', 'formats'})
|
self.compare_metadata(nmi, oldmi, exclude={'last_modified', 'format_metadata', 'formats'})
|
||||||
cache.set_metadata(1, mi2, force_changes=True)
|
cache.set_metadata(1, mi2, force_changes=True)
|
||||||
nmi2 = cache.get_metadata(1, get_cover=True, cover_as_data=True)
|
nmi2 = cache.get_metadata(1, get_cover=True, cover_as_data=True)
|
||||||
# The new code does not allow setting of #series_index to None, instead
|
self.compare_metadata(nmi2, oldmi2, exclude={'last_modified', 'format_metadata', 'formats'})
|
||||||
# it is reset to 1.0
|
|
||||||
ae(nmi2.get_extra('#series'), 1.0)
|
|
||||||
self.compare_metadata(nmi2, oldmi2, exclude={'last_modified', 'format_metadata', '#series_index', 'formats'})
|
|
||||||
|
|
||||||
cache = self.init_cache(self.cloned_library)
|
cache = self.init_cache(self.cloned_library)
|
||||||
mi = cache.get_metadata(1)
|
mi = cache.get_metadata(1)
|
||||||
|
@ -233,13 +233,19 @@ def one_one_in_other(book_id_val_map, db, field, *args):
|
|||||||
def custom_series_index(book_id_val_map, db, field, *args):
|
def custom_series_index(book_id_val_map, db, field, *args):
|
||||||
series_field = field.series_field
|
series_field = field.series_field
|
||||||
sequence = []
|
sequence = []
|
||||||
for book_id, sidx in iteritems(book_id_val_map):
|
for book_id, sidx in book_id_val_map.items():
|
||||||
if sidx is None:
|
if sidx is None:
|
||||||
sidx = 1.0
|
sidx = 1.0
|
||||||
ids = series_field.ids_for_book(book_id)
|
ids = series_field.ids_for_book(book_id)
|
||||||
if ids:
|
if ids:
|
||||||
sequence.append((sidx, book_id, ids[0]))
|
sequence.append((sidx, book_id, ids[0]))
|
||||||
field.table.book_col_map[book_id] = sidx
|
field.table.book_col_map[book_id] = sidx
|
||||||
|
else:
|
||||||
|
# the series has been deleted from the book, which means no row for
|
||||||
|
# it exists in the series table. The series_index value should be
|
||||||
|
# removed from the in-memory table as well, to ensure this book
|
||||||
|
# sorts the same as other books with no series.
|
||||||
|
field.table.remove_books((book_id,), db)
|
||||||
if sequence:
|
if sequence:
|
||||||
db.executemany('UPDATE %s SET %s=? WHERE book=? AND value=?'%(
|
db.executemany('UPDATE %s SET %s=? WHERE book=? AND value=?'%(
|
||||||
field.metadata['table'], field.metadata['column']), sequence)
|
field.metadata['table'], field.metadata['column']), sequence)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user