fix(license-import): don't crash if license file is not present, and only run this code for EE

This commit is contained in:
RhodeCode Admin 2024-10-04 12:54:37 +02:00
parent 5fc38bda7c
commit 4bc763e2d0

View file

@ -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):