Show More
@@ -165,9 +165,6 b' def load_environment(global_conf, app_co' | |||||
165 | if vcs_server_enabled: |
|
165 | if vcs_server_enabled: | |
166 | connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(config)) |
|
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 | return config |
|
168 | return config | |
172 |
|
169 | |||
173 |
|
170 |
@@ -34,6 +34,7 b' from pyramid.settings import asbool, asl' | |||||
34 | from pyramid.wsgi import wsgiapp |
|
34 | from pyramid.wsgi import wsgiapp | |
35 | from pyramid.httpexceptions import HTTPError, HTTPInternalServerError |
|
35 | from pyramid.httpexceptions import HTTPError, HTTPInternalServerError | |
36 | from pylons.controllers.util import abort, redirect |
|
36 | from pylons.controllers.util import abort, redirect | |
|
37 | from pyramid.events import ApplicationCreated | |||
37 | import pyramid.httpexceptions as httpexceptions |
|
38 | import pyramid.httpexceptions as httpexceptions | |
38 | from pyramid.renderers import render_to_response, render |
|
39 | from pyramid.renderers import render_to_response, render | |
39 | from routes.middleware import RoutesMiddleware |
|
40 | from routes.middleware import RoutesMiddleware | |
@@ -51,6 +52,7 b' from rhodecode.lib.middleware.disable_vc' | |||||
51 | from rhodecode.lib.middleware.https_fixup import HttpsFixup |
|
52 | from rhodecode.lib.middleware.https_fixup import HttpsFixup | |
52 | from rhodecode.lib.middleware.vcs import VCSMiddleware |
|
53 | from rhodecode.lib.middleware.vcs import VCSMiddleware | |
53 | from rhodecode.lib.plugins.utils import register_rhodecode_plugin |
|
54 | from rhodecode.lib.plugins.utils import register_rhodecode_plugin | |
|
55 | from rhodecode.subscribers import scan_repositories_if_enabled | |||
54 |
|
56 | |||
55 |
|
57 | |||
56 | log = logging.getLogger(__name__) |
|
58 | log = logging.getLogger(__name__) | |
@@ -257,6 +259,9 b' def includeme(config):' | |||||
257 | config.add_route( |
|
259 | config.add_route( | |
258 | 'rhodecode_support', 'https://rhodecode.com/help/', static=True) |
|
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 | # Set the authorization policy. |
|
265 | # Set the authorization policy. | |
261 | authz_policy = ACLAuthorizationPolicy() |
|
266 | authz_policy = ACLAuthorizationPolicy() | |
262 | config.set_authorization_policy(authz_policy) |
|
267 | config.set_authorization_policy(authz_policy) |
@@ -53,3 +53,18 b' def add_localizer(event):' | |||||
53 |
|
53 | |||
54 | request.localizer = localizer |
|
54 | request.localizer = localizer | |
55 | request.translate = auto_translate |
|
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