151
153
run a background timer to see if the a-x-i data we have is
152
154
still fresh or if the cache has changed since
154
if not self.db._aptcache.ready:
156
# see if we need a a-x-i update
157
if self._check_for_channel_updates():
158
# this will trigger a "channels-changed" signal from
159
# the backend object once a-x-i is finished
160
self._logger.debug("running update_xapian_index")
161
self.backend.update_xapian_index()
156
# this is expensive and does not need UI to we shove it out
157
channel_update = os.path.join(
158
softwarecenter.paths.datadir, "update-software-center-channels")
159
(pid, stdin, stdout, stderr) = GObject.spawn_async(
161
flags=GObject.SPAWN_DO_NOT_REAP_CHILD)
162
GObject.child_watch_add(
163
pid, self._on_check_for_channel_updates_finished)
164
def _check_for_channel_updates(self):
166
check current set of channel origins in a-x-i and
167
compare it to the apt cache to see if
168
anything has changed,
170
returns True is a update is needed
172
# the operation get_origins can take some time (~60s?)
173
cache_origins = set(self.db._aptcache.get_all_origins())
174
db_origins = set(self.db.get_origins_from_db())
176
self._logger.debug("cache_origins: %s" % cache_origins)
177
self._logger.debug("db_origins: %s" % db_origins)
178
# the db_origins will contain origins from the s-c-agent, so
179
# we don't need to rebuild if the db has more origins then
180
# the cache, but we need to rebuild if the cache has origins
181
# that a-x-i does not have
182
if not cache_origins.issubset(db_origins):
165
def _on_check_for_channel_updates_finished(self, pid, condition):
166
# exit status of 1 means stuff changed
167
if os.WEXITSTATUS(condition) == 1:
186
170
def _get_channels(self, installed_only=False):