mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix duplicate detection when adding books not working when the book title has leading or trailing whitespace
This commit is contained in:
parent
bac981756c
commit
f0d003ce30
@ -1480,7 +1480,7 @@ class Cache(object):
|
|||||||
if title:
|
if title:
|
||||||
if isbytestring(title):
|
if isbytestring(title):
|
||||||
title = title.decode(preferred_encoding, 'replace')
|
title = title.decode(preferred_encoding, 'replace')
|
||||||
q = icu_lower(title)
|
q = icu_lower(title).strip()
|
||||||
for title in self.fields['title'].table.book_col_map.itervalues():
|
for title in self.fields['title'].table.book_col_map.itervalues():
|
||||||
if q == icu_lower(title):
|
if q == icu_lower(title):
|
||||||
return True
|
return True
|
||||||
|
@ -60,11 +60,13 @@ def run_import_plugins(paths, group_id, tdir):
|
|||||||
final_paths.append(path)
|
final_paths.append(path)
|
||||||
return final_paths
|
return final_paths
|
||||||
|
|
||||||
|
def has_book(mi, data_for_has_book):
|
||||||
|
return mi.title and icu_lower(mi.title.strip()) in data_for_has_book
|
||||||
|
|
||||||
def read_metadata(paths, group_id, tdir, common_data=None):
|
def read_metadata(paths, group_id, tdir, common_data=None):
|
||||||
paths = run_import_plugins(paths, group_id, tdir)
|
paths = run_import_plugins(paths, group_id, tdir)
|
||||||
mi, opf, has_cover = serialize_metadata_for(paths, tdir, group_id)
|
mi, opf, has_cover = serialize_metadata_for(paths, tdir, group_id)
|
||||||
duplicate_info = None
|
duplicate_info = None
|
||||||
if common_data is not None:
|
if isinstance(common_data, (set, frozenset)):
|
||||||
if isinstance(common_data, (set, frozenset)):
|
duplicate_info = has_book(mi, common_data)
|
||||||
duplicate_info = mi.title and icu_lower(mi.title) in common_data
|
|
||||||
return paths, opf, has_cover, duplicate_info
|
return paths, opf, has_cover, duplicate_info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user