summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-01-05 18:25:27 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-01-05 18:32:57 +0100
commit33dc1288cbfe857ad6e6a46ea4365f125c78f044 (patch)
tree0650dc64abdf8cb64698777885cc4acea49e5f52
parent5c21ce976e525fa8550831e6fd424e3536692c64 (diff)
downloadqutebrowser-33dc1288cbfe857ad6e6a46ea4365f125c78f044.tar.gz
qutebrowser-33dc1288cbfe857ad6e6a46ea4365f125c78f044.zip
history: Don't query SQL to rebuild completion
Instead of using an empty table as a trigger to rebuild, use a simple flag. If the user wants to force a rebuild, they can set the user version to 0 instead.
-rw-r--r--qutebrowser/browser/history.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py
index ecd96eecc..2d330c269 100644
--- a/qutebrowser/browser/history.py
+++ b/qutebrowser/browser/history.py
@@ -167,6 +167,8 @@ class WebHistory(sql.SqlTable):
self.completion = CompletionHistory(parent=self)
self.metainfo = CompletionMetaInfo(parent=self)
+ rebuild_completion = False
+
if sql.db_user_version != sql.USER_VERSION:
# If the DB user version changed, run a full cleanup and rebuild the
# completion history.
@@ -176,7 +178,7 @@ class WebHistory(sql.SqlTable):
# gives us less corner-cases to deal with, and we can run a VACUUM to make
# things smaller.
self._cleanup_history()
- self.completion.delete_all()
+ rebuild_completion = True
# Get a string of all patterns
patterns = config.instance.get_str('completion.web_history.exclude')
@@ -184,10 +186,9 @@ class WebHistory(sql.SqlTable):
# If patterns changed, update them in database and rebuild completion
if self.metainfo['excluded_patterns'] != patterns:
self.metainfo['excluded_patterns'] = patterns
- self.completion.delete_all()
+ rebuild_completion = True
- if not self.completion:
- # either the table is out-of-date or the user wiped it manually
+ if rebuild_completion:
self._rebuild_completion()
self.create_index('HistoryIndex', 'url')
@@ -266,7 +267,11 @@ class WebHistory(sql.SqlTable):
self._progress.start("Rebuilding completion...")
- # select the latest entry for each url
+ # Delete old entries
+ self.completion.delete_all()
+ QApplication.processEvents()
+
+ # Select the latest entry for each url
q = sql.Query('SELECT url, title, max(atime) AS atime FROM History '
'WHERE NOT redirect '
'GROUP BY url ORDER BY atime asc')