##// END OF EJS Templates
config: Move initial repo scan up to the pyramid layer....
Martin Bornhold -
r580:b2c504de default
parent child Browse files
Show More
@@ -165,9 +165,6 b' def load_environment(global_conf, app_co'
165 165 if vcs_server_enabled:
166 166 connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(config))
167 167
168 import_on_startup = str2bool(config.get('startup.import_repos', False))
169 if vcs_server_enabled and import_on_startup:
170 repo2db_mapper(ScmModel().repo_scan(repos_path), remove_obsolete=False)
171 168 return config
172 169
173 170
@@ -34,6 +34,7 b' from pyramid.settings import asbool, asl'
34 34 from pyramid.wsgi import wsgiapp
35 35 from pyramid.httpexceptions import HTTPError, HTTPInternalServerError
36 36 from pylons.controllers.util import abort, redirect
37 from pyramid.events import ApplicationCreated
37 38 import pyramid.httpexceptions as httpexceptions
38 39 from pyramid.renderers import render_to_response, render
39 40 from routes.middleware import RoutesMiddleware
@@ -51,6 +52,7 b' from rhodecode.lib.middleware.disable_vc'
51 52 from rhodecode.lib.middleware.https_fixup import HttpsFixup
52 53 from rhodecode.lib.middleware.vcs import VCSMiddleware
53 54 from rhodecode.lib.plugins.utils import register_rhodecode_plugin
55 from rhodecode.subscribers import scan_repositories_if_enabled
54 56
55 57
56 58 log = logging.getLogger(__name__)
@@ -257,6 +259,9 b' def includeme(config):'
257 259 config.add_route(
258 260 'rhodecode_support', 'https://rhodecode.com/help/', static=True)
259 261
262 # Add subscribers.
263 config.add_subscriber(scan_repositories_if_enabled, ApplicationCreated)
264
260 265 # Set the authorization policy.
261 266 authz_policy = ACLAuthorizationPolicy()
262 267 config.set_authorization_policy(authz_policy)
@@ -53,3 +53,18 b' def add_localizer(event):'
53 53
54 54 request.localizer = localizer
55 55 request.translate = auto_translate
56
57
58 def scan_repositories_if_enabled(event):
59 """
60 This is subscribed to the `pyramid.events.ApplicationCreated` event. It
61 does a repository scan if enabled in the settings.
62 """
63 from rhodecode.model.scm import ScmModel
64 from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_base_path
65 settings = event.app.registry.settings
66 vcs_server_enabled = settings['vcs.server.enable']
67 import_on_startup = settings['startup.import_repos']
68 if vcs_server_enabled and import_on_startup:
69 repositories = ScmModel().repo_scan(get_rhodecode_base_path())
70 repo2db_mapper(repositories, remove_obsolete=False)
General Comments 0
You need to be logged in to leave comments. Login now