##// END OF EJS Templates
fix(license-import): don't crash if license file is not present, and only run this code for EE
super-admin -
r5538:aa408762 default
parent child Browse files
Show More
@@ -111,9 +111,11 b' def scan_repositories_if_enabled(event):'
111 This is subscribed to the `pyramid.events.ApplicationCreated` event. It
111 This is subscribed to the `pyramid.events.ApplicationCreated` event. It
112 does a repository scan if enabled in the settings.
112 does a repository scan if enabled in the settings.
113 """
113 """
114
114 settings = event.app.registry.settings
115 settings = event.app.registry.settings
115 vcs_server_enabled = settings['vcs.server.enable']
116 vcs_server_enabled = settings['vcs.server.enable']
116 import_on_startup = settings['startup.import_repos']
117 import_on_startup = settings['startup.import_repos']
118
117 if vcs_server_enabled and import_on_startup:
119 if vcs_server_enabled and import_on_startup:
118 from rhodecode.model.scm import ScmModel
120 from rhodecode.model.scm import ScmModel
119 from rhodecode.lib.utils import repo2db_mapper
121 from rhodecode.lib.utils import repo2db_mapper
@@ -320,13 +322,19 b' def import_license_if_present(event):'
320 """
322 """
321 settings = event.app.registry.settings
323 settings = event.app.registry.settings
322
324
325 rhodecode_edition_id = settings.get('rhodecode.edition_id')
323 license_file_path = settings.get('license.import_path')
326 license_file_path = settings.get('license.import_path')
324 force = settings.get('license.import_path_mode') == 'force'
327 force = settings.get('license.import_path_mode') == 'force'
325 if license_file_path:
328
329 if license_file_path and rhodecode_edition_id == 'EE':
330 log.debug('license.import_path= is set importing license from %s', license_file_path)
326 from rhodecode.model.meta import Session
331 from rhodecode.model.meta import Session
327 from rhodecode.model.license import apply_license_from_file
332 from rhodecode.model.license import apply_license_from_file
328 apply_license_from_file(license_file_path, force=force)
333 try:
329 Session().commit()
334 apply_license_from_file(license_file_path, force=force)
335 Session().commit()
336 except OSError:
337 log.exception('Failed to import license from %s, make sure this file exists', license_file_path)
330
338
331
339
332 class Subscriber(object):
340 class Subscriber(object):
General Comments 0
You need to be logged in to leave comments. Login now