diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 2dc5d557f7..7ed653093c 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -1057,7 +1057,7 @@ class Cache(object): @write_api def set_metadata(self, book_id, mi, ignore_errors=False, force_changes=False, - set_title=True, set_authors=True): + set_title=True, set_authors=True, allow_case_change=False): ''' Set metadata for the book `id` from the `Metadata` object `mi` @@ -1078,13 +1078,13 @@ class Cache(object): except (AttributeError, TypeError): pass - def set_field(name, val, **kwargs): - self._set_field(name, {book_id:val}, **kwargs) + def set_field(name, val): + self._set_field(name, {book_id:val}, do_path_update=False, allow_case_change=allow_case_change) path_changed = False if set_title and mi.title: path_changed = True - set_field('title', mi.title, do_path_update=False) + set_field('title', mi.title) if set_authors: path_changed = True if not mi.authors: @@ -1092,7 +1092,7 @@ class Cache(object): authors = [] for a in mi.authors: authors += string_to_authors(a) - set_field('authors', authors, do_path_update=False) + set_field('authors', authors) if path_changed: self._update_path({book_id}) diff --git a/src/calibre/db/tests/writing.py b/src/calibre/db/tests/writing.py index 19f6e70f48..f4b8553164 100644 --- a/src/calibre/db/tests/writing.py +++ b/src/calibre/db/tests/writing.py @@ -420,6 +420,13 @@ class WritingTest(BaseTest): ae(nmi2.get_extra('#series'), 1.0) self.compare_metadata(nmi2, oldmi2, exclude={'last_modified', 'format_metadata', '#series_index'}) + cache = self.init_cache(self.cloned_library) + mi = cache.get_metadata(1) + otags = mi.tags + mi.tags = [x.upper() for x in mi.tags] + cache.set_metadata(3, mi) + self.assertEqual(set(otags), set(cache.field_for('tags', 3)), 'case changes should not be allowed in set_metadata') + # }}} def test_conversion_options(self): # {{{ @@ -574,4 +581,3 @@ class WritingTest(BaseTest): cache.add_format(1, 'ADD', BytesIO(b'xxxx')) test_invalidate() # }}} -