mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Take out commit= parameter on set_authors and set_title. Change other code where necessary
This commit is contained in:
parent
8a3aa64776
commit
ba6f2f0c5e
@ -484,7 +484,10 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
setter = self.db.set_comment
|
setter = self.db.set_comment
|
||||||
else:
|
else:
|
||||||
setter = getattr(self.db, 'set_'+dest)
|
setter = getattr(self.db, 'set_'+dest)
|
||||||
setter(id, val, notify=False, commit=False)
|
if dest in ['title', 'authors']:
|
||||||
|
setter(id, val, notify=False)
|
||||||
|
else:
|
||||||
|
setter(id, val, notify=False, commit=False)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
dynamic['s_r_search_mode'] = self.search_mode.currentIndex()
|
dynamic['s_r_search_mode'] = self.search_mode.currentIndex()
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
path = path.lower()
|
path = path.lower()
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def set_path(self, index, index_is_id=False, commit=True):
|
def set_path(self, index, index_is_id=False):
|
||||||
'''
|
'''
|
||||||
Set the path to the directory containing this books files based on its
|
Set the path to the directory containing this books files based on its
|
||||||
current title and author. If there was a previous directory, its contents
|
current title and author. If there was a previous directory, its contents
|
||||||
@ -447,8 +447,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.add_format(id, format, stream, index_is_id=True,
|
self.add_format(id, format, stream, index_is_id=True,
|
||||||
path=tpath, notify=False)
|
path=tpath, notify=False)
|
||||||
self.conn.execute('UPDATE books SET path=? WHERE id=?', (path, id))
|
self.conn.execute('UPDATE books SET path=? WHERE id=?', (path, id))
|
||||||
if commit:
|
self.conn.commit()
|
||||||
self.conn.commit()
|
|
||||||
self.data.set(id, self.FIELD_MAP['path'], path, row_is_id=True)
|
self.data.set(id, self.FIELD_MAP['path'], path, row_is_id=True)
|
||||||
# Delete not needed directories
|
# Delete not needed directories
|
||||||
if current_path and os.path.exists(spath):
|
if current_path and os.path.exists(spath):
|
||||||
@ -1212,7 +1211,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
result.append(r)
|
result.append(r)
|
||||||
return ' & '.join(result).replace('|', ',')
|
return ' & '.join(result).replace('|', ',')
|
||||||
|
|
||||||
def set_authors(self, id, authors, notify=True, commit=True):
|
def set_authors(self, id, authors, notify=True):
|
||||||
'''
|
'''
|
||||||
`authors`: A list of authors.
|
`authors`: A list of authors.
|
||||||
'''
|
'''
|
||||||
@ -1240,17 +1239,16 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
ss = self.author_sort_from_book(id, index_is_id=True)
|
ss = self.author_sort_from_book(id, index_is_id=True)
|
||||||
self.conn.execute('UPDATE books SET author_sort=? WHERE id=?',
|
self.conn.execute('UPDATE books SET author_sort=? WHERE id=?',
|
||||||
(ss, id))
|
(ss, id))
|
||||||
if commit:
|
self.conn.commit()
|
||||||
self.conn.commit()
|
|
||||||
self.data.set(id, self.FIELD_MAP['authors'],
|
self.data.set(id, self.FIELD_MAP['authors'],
|
||||||
','.join([a.replace(',', '|') for a in authors]),
|
','.join([a.replace(',', '|') for a in authors]),
|
||||||
row_is_id=True)
|
row_is_id=True)
|
||||||
self.data.set(id, self.FIELD_MAP['author_sort'], ss, row_is_id=True)
|
self.data.set(id, self.FIELD_MAP['author_sort'], ss, row_is_id=True)
|
||||||
self.set_path(id, index_is_id=True, commit=commit)
|
self.set_path(id, index_is_id=True)
|
||||||
if notify:
|
if notify:
|
||||||
self.notify('metadata', [id])
|
self.notify('metadata', [id])
|
||||||
|
|
||||||
def set_title(self, id, title, notify=True, commit=True):
|
def set_title(self, id, title, notify=True):
|
||||||
if not title:
|
if not title:
|
||||||
return
|
return
|
||||||
if not isinstance(title, unicode):
|
if not isinstance(title, unicode):
|
||||||
@ -1261,9 +1259,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.data.set(id, self.FIELD_MAP['sort'], title_sort(title), row_is_id=True)
|
self.data.set(id, self.FIELD_MAP['sort'], title_sort(title), row_is_id=True)
|
||||||
else:
|
else:
|
||||||
self.data.set(id, self.FIELD_MAP['sort'], title, row_is_id=True)
|
self.data.set(id, self.FIELD_MAP['sort'], title, row_is_id=True)
|
||||||
self.set_path(id, index_is_id=True, commit=commit)
|
self.set_path(id, index_is_id=True)
|
||||||
if commit:
|
self.conn.commit()
|
||||||
self.conn.commit()
|
|
||||||
if notify:
|
if notify:
|
||||||
self.notify('metadata', [id])
|
self.notify('metadata', [id])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user