diff --git a/kallithea/controllers/admin/settings.py b/kallithea/controllers/admin/settings.py --- a/kallithea/controllers/admin/settings.py +++ b/kallithea/controllers/admin/settings.py @@ -36,6 +36,7 @@ from tg.i18n import ugettext as _ from webob.exc import HTTPFound import kallithea +import kallithea.lib.indexers.daemon from kallithea.controllers import base from kallithea.lib import webutils from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired @@ -378,7 +379,7 @@ class SettingsController(base.BaseContro if request.POST: repo_location = self._get_hg_ui_settings()['paths_root_path'] full_index = request.POST.get('full_index', False) - async_tasks.whoosh_index(repo_location, full_index) + kallithea.lib.indexers.daemon.whoosh_index(repo_location, full_index) webutils.flash(_('Whoosh reindex task scheduled'), category='success') raise HTTPFound(location=url('admin_settings_search')) diff --git a/kallithea/lib/celery_app.py b/kallithea/lib/celery_app.py --- a/kallithea/lib/celery_app.py +++ b/kallithea/lib/celery_app.py @@ -18,7 +18,10 @@ import logging class CeleryConfig(object): - imports = ['kallithea.model.async_tasks'] + imports = [ + 'kallithea.lib.indexers.daemon', + 'kallithea.model.async_tasks', + ] task_always_eager = False list_config_names = {'imports', 'accept_content'} diff --git a/kallithea/lib/indexers/daemon.py b/kallithea/lib/indexers/daemon.py --- a/kallithea/lib/indexers/daemon.py +++ b/kallithea/lib/indexers/daemon.py @@ -32,9 +32,11 @@ import traceback from shutil import rmtree from time import mktime +from tg import config from whoosh.index import create_in, exists_in, open_dir from whoosh.qparser import QueryParser +from kallithea.lib import celerylib from kallithea.lib.conf import INDEX_EXTENSIONS, INDEX_FILENAMES from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA from kallithea.lib.utils2 import safe_str @@ -444,3 +446,12 @@ class WhooshIndexingDaemon(object): self.build_indexes() else: self.update_indexes() + + +@celerylib.task +@celerylib.locked_task +def whoosh_index(repo_location, full_index): + index_location = config['index_dir'] + WhooshIndexingDaemon(index_location=index_location, + repo_location=repo_location) \ + .run(full_index=full_index) diff --git a/kallithea/model/async_tasks.py b/kallithea/model/async_tasks.py --- a/kallithea/model/async_tasks.py +++ b/kallithea/model/async_tasks.py @@ -41,27 +41,17 @@ from tg import config import kallithea from kallithea.lib import celerylib, conf, ext_json, hooks -from kallithea.lib.indexers.daemon import WhooshIndexingDaemon from kallithea.lib.utils2 import asbool, ascii_bytes from kallithea.lib.vcs.utils import author_email, author_name from kallithea.model import db, meta, repo, userlog -__all__ = ['whoosh_index', 'get_commits_stats', 'send_email'] +__all__ = ['get_commits_stats', 'send_email'] log = celery.utils.log.get_task_logger(__name__) -@celerylib.task -@celerylib.locked_task -def whoosh_index(repo_location, full_index): - index_location = config['index_dir'] - WhooshIndexingDaemon(index_location=index_location, - repo_location=repo_location) \ - .run(full_index=full_index) - - def _author_username(author): """Return the username of the user identified by the email part of the 'author' string, default to the name or email. diff --git a/scripts/deps.py b/scripts/deps.py --- a/scripts/deps.py +++ b/scripts/deps.py @@ -159,7 +159,6 @@ known_violations = set([ ('kallithea.lib.utils', 'kallithea.model.db'), ('kallithea.lib.utils', 'kallithea.model.scm'), ('kallithea.model.async_tasks', 'kallithea.lib.hooks'), -('kallithea.model.async_tasks', 'kallithea.lib.indexers'), ('kallithea.model.async_tasks', 'kallithea.model'), ('kallithea.model', 'kallithea.lib.auth'), # auth.HasXXX ('kallithea.model', 'kallithea.lib.auth_modules'), # validators