Unity lens: reconnect to db from time to time to get fresh results
This commit is contained in:
parent
aef5b80d6b
commit
bed7012fef
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
from gi.repository import GLib, GObject, Gio
|
from gi.repository import GLib, GObject, Gio
|
||||||
from gi.repository import Dee
|
from gi.repository import Dee
|
||||||
@ -41,15 +42,14 @@ class Scope (Unity.Scope):
|
|||||||
self.connect ("filters-changed",
|
self.connect ("filters-changed",
|
||||||
self._on_filters_changed)
|
self._on_filters_changed)
|
||||||
|
|
||||||
|
self.last_connect_time = 0
|
||||||
# Connect to the index
|
|
||||||
self.db = recoll.connect()
|
|
||||||
|
|
||||||
self.db.setAbstractParams(maxchars=200,
|
|
||||||
contextwords=4)
|
|
||||||
|
|
||||||
self.timeout_id = None
|
self.timeout_id = None
|
||||||
|
|
||||||
|
def _connect_db(self):
|
||||||
|
#print "Connecting to db"
|
||||||
|
self.db = recoll.connect()
|
||||||
|
self.db.setAbstractParams(maxchars=200, contextwords=4)
|
||||||
|
|
||||||
def get_search_string (self):
|
def get_search_string (self):
|
||||||
search = self.props.active_search
|
search = self.props.active_search
|
||||||
return search.props.search_string if search else None
|
return search.props.search_string if search else None
|
||||||
@ -144,6 +144,11 @@ class Scope (Unity.Scope):
|
|||||||
if search_string == "":
|
if search_string == "":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
current_time = time.time()
|
||||||
|
if current_time - self.last_connect_time > 10:
|
||||||
|
self._connect_db()
|
||||||
|
self.last_connect_time = current_time
|
||||||
|
|
||||||
fcat = self.get_filter("rclcat")
|
fcat = self.get_filter("rclcat")
|
||||||
for option in fcat.options:
|
for option in fcat.options:
|
||||||
if option.props.active:
|
if option.props.active:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user