# HG changeset patch # User RhodeCode Admin # Date 2024-10-04 10:54:37 # Node ID aa4087623e25939662ff873c2cd268a83805f2f8 # Parent 7cab32aee3bc66dc654604bf6423b56deb520371 fix(license-import): don't crash if license file is not present, and only run this code for EE diff --git a/rhodecode/subscribers.py b/rhodecode/subscribers.py --- a/rhodecode/subscribers.py +++ b/rhodecode/subscribers.py @@ -111,9 +111,11 @@ def scan_repositories_if_enabled(event): This is subscribed to the `pyramid.events.ApplicationCreated` event. It does a repository scan if enabled in the settings. """ + settings = event.app.registry.settings vcs_server_enabled = settings['vcs.server.enable'] import_on_startup = settings['startup.import_repos'] + if vcs_server_enabled and import_on_startup: from rhodecode.model.scm import ScmModel from rhodecode.lib.utils import repo2db_mapper @@ -320,13 +322,19 @@ def import_license_if_present(event): """ settings = event.app.registry.settings + rhodecode_edition_id = settings.get('rhodecode.edition_id') license_file_path = settings.get('license.import_path') force = settings.get('license.import_path_mode') == 'force' - if license_file_path: + + if license_file_path and rhodecode_edition_id == 'EE': + log.debug('license.import_path= is set importing license from %s', license_file_path) from rhodecode.model.meta import Session from rhodecode.model.license import apply_license_from_file - apply_license_from_file(license_file_path, force=force) - Session().commit() + try: + apply_license_from_file(license_file_path, force=force) + Session().commit() + except OSError: + log.exception('Failed to import license from %s, make sure this file exists', license_file_path) class Subscriber(object):