From ef3265a424e3f474758e17bd2e40d06d8b646f1d Mon Sep 17 00:00:00 2001 From: Bluefox Date: Wed, 20 Sep 2023 09:08:50 +0200 Subject: [PATCH] If no configuration found, or adapter was not properly installed, check it. (#2418) * If no configuration found, or adapter was not properly installed, check it. * do not crash hard if plugins could not be added --------- Co-authored-by: Max Hauser --- packages/adapter/src/lib/adapter/adapter.ts | 9 ++++++--- packages/common/src/lib/common/tools.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/adapter/src/lib/adapter/adapter.ts b/packages/adapter/src/lib/adapter/adapter.ts index 0fb8196104..4a0f3e5432 100644 --- a/packages/adapter/src/lib/adapter/adapter.ts +++ b/packages/adapter/src/lib/adapter/adapter.ts @@ -11885,7 +11885,7 @@ export class AdapterClass extends EventEmitter { // give it a chance to handle the error itself instead of restarting it if (typeof this._options.error === 'function') { try { - // if error handler in the adapter returned exactly true, + // if the error handler in the adapter returned exactly true, // we expect the error to be handled and do nothing more const wasHandled = this._options.error(err); if (wasHandled === true) { @@ -12178,8 +12178,11 @@ export class AdapterClass extends EventEmitter { }; this.pluginHandler = new PluginHandler(pluginSettings); - this.pluginHandler.addPlugins(this.ioPack.common.plugins, [this.adapterDir, __dirname]); // first resolve from adapter directory, else from js-controller - + try { + this.pluginHandler.addPlugins(this.ioPack.common.plugins, [this.adapterDir, __dirname]); // first resolve from adapter directory, else from js-controller + } catch (e) { + this._logger.error(`Could not add plugins: ${e.message}`); + } // finally init _initDBs(); } diff --git a/packages/common/src/lib/common/tools.ts b/packages/common/src/lib/common/tools.ts index e0cd7c4757..f35656e958 100644 --- a/packages/common/src/lib/common/tools.ts +++ b/packages/common/src/lib/common/tools.ts @@ -1525,7 +1525,7 @@ export async function sendDiagInfo(obj: Record): Promise { */ export function getAdapterDir(adapter: string): string | null { // snip off 'iobroker.' - if (adapter.toLowerCase().startsWith(appName.toLowerCase() + '.')) { + if (adapter.toLowerCase().startsWith(`${appNameLowerCase}.`)) { adapter = adapter.substring(appName.length + 1); } // snip off instance id