mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-02-03 01:23:31 -05:00
Check library: Add an option to rebuild the annotations search index
See #2139555 (Private bug)
This commit is contained in:
parent
e39cd5a1f2
commit
0bb3b9a2d5
@ -1462,8 +1462,11 @@ class DB:
|
||||
finally:
|
||||
self.reopen()
|
||||
|
||||
def vacuum(self, include_fts_db, include_notes_db):
|
||||
def vacuum(self, include_fts_db, include_notes_db, rebuild_annotations_fts):
|
||||
self.execute('VACUUM')
|
||||
if rebuild_annotations_fts:
|
||||
self.execute('INSERT INTO annotations_fts(annotations_fts) VALUES("rebuild");')
|
||||
self.execute('INSERT INTO annotations_fts_stemmed(annotations_fts_stemmed) VALUES("rebuild");')
|
||||
if self.fts_enabled and include_fts_db:
|
||||
self.fts.vacuum()
|
||||
if include_notes_db:
|
||||
|
||||
@ -2999,10 +2999,10 @@ class Cache:
|
||||
return self.backend.dump_and_restore(callback=callback, sql=sql)
|
||||
|
||||
@write_api
|
||||
def vacuum(self, include_fts_db=False, include_notes_db=True):
|
||||
def vacuum(self, include_fts_db=False, include_notes_db=True, rebuild_annotations_fts=False):
|
||||
self.is_doing_rebuild_or_vacuum = True
|
||||
try:
|
||||
self.backend.vacuum(include_fts_db, include_notes_db)
|
||||
self.backend.vacuum(include_fts_db, include_notes_db, rebuild_annotations_fts)
|
||||
finally:
|
||||
self.is_doing_rebuild_or_vacuum = False
|
||||
|
||||
|
||||
@ -64,6 +64,13 @@ class DBCheck(QDialog): # {{{
|
||||
la.setWordWrap(True)
|
||||
l.addWidget(la)
|
||||
|
||||
self.annots = a = QCheckBox(_('Also rebuild the annotations search index'))
|
||||
l.addWidget(a)
|
||||
la = QLabel('<p style="margin-left: 20px; font-style: italic">' + _(
|
||||
'This can be a slow operation, depending on the number of annotations you have.'))
|
||||
la.setWordWrap(True)
|
||||
l.addWidget(la)
|
||||
|
||||
self.fts = f = QCheckBox(_('Also compact the Full text search database'))
|
||||
l.addWidget(f)
|
||||
la = QLabel('<p style="margin-left: 20px; font-style: italic">' + _(
|
||||
@ -106,12 +113,13 @@ class DBCheck(QDialog): # {{{
|
||||
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||
self.vacuum_started = True
|
||||
db = self.db()
|
||||
t = self.thread = Thread(target=self.vacuum, args=(db, self.fts.isChecked(), self.notes.isChecked()), daemon=True, name='VacuumDB')
|
||||
t = self.thread = Thread(target=self.vacuum, args=(
|
||||
db, self.fts.isChecked(), self.notes.isChecked(), self.annots.isChecked()), daemon=True, name='VacuumDB')
|
||||
t.start()
|
||||
|
||||
def vacuum(self, db, include_fts_db, include_notes_db):
|
||||
def vacuum(self, db, include_fts_db, include_notes_db, rebuild_annotations_fts):
|
||||
try:
|
||||
db.vacuum(include_fts_db, include_notes_db)
|
||||
db.vacuum(include_fts_db, include_notes_db, rebuild_annotations_fts)
|
||||
except Exception as e:
|
||||
import traceback
|
||||
self.error = (as_unicode(e), traceback.format_exc())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user