Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for extension config loading (issue #847) #884

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/backend/model/extension/ExtensionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {SQLConnection} from '../database/SQLConnection';
import {ExtensionObject} from './ExtensionObject';
import {ExtensionDecoratorObject} from './ExtensionDecorator';
import * as util from 'util';
import {ServerExtensionsEntryConfig} from '../../../common/config/private/subconfigs/ServerExtensionsConfig';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const exec = util.promisify(require('child_process').exec);

Expand Down Expand Up @@ -79,6 +80,14 @@ export class ExtensionManager implements IObjectManager {
);
extList.sort();

// delete not existing extensions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wanted to avoid this. (i.e.: I removed this laoding here on porpuse.)

I would like to have a single place that is responsible loading extension config (even if they do not exists, then its an empty config).
That is why I moved all code to the extension config loader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a closer look at the extension config loader. I didn't see anywhere else that Config.Extensions.extensions.push(new ServerExtensionsEntryConfig(ep))); happened, so the extension configs never actually got loaded into Config.

Config.Extensions.extensions = Config.Extensions.extensions.filter(ec => extList.indexOf(ec.path) !== -1);


// Add new extensions
const ePaths = Config.Extensions.extensions.map(ec => ec.path);
extList.filter(ep => ePaths.indexOf(ep) === -1).forEach(ep =>
Config.Extensions.extensions.push(new ServerExtensionsEntryConfig(ep)));

Logger.debug(LOG_TAG, 'Extensions found: ', JSON.stringify(Config.Extensions.extensions.map(ec => ec.path)));
}
Expand Down
6 changes: 5 additions & 1 deletion src/common/config/private/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import * as path from 'path';

const pre = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass());
try {
//NOTE: can possibly remove this saveIfNotExist hack if typeconfig issue #27 is fixed
const origSaveIfNotExist = (pre.__options as any).saveIfNotExist;
(pre.__options as any).saveIfNotExist = false;
pre.loadSync();
(pre.__options as any).saveIfNotExist = origSaveIfNotExist;
} catch (e) { /* empty */ }
ExtensionConfigTemplateLoader.Instance.init(path.join(__dirname, '/../../../../', pre.Extensions.folder));
ExtensionConfigTemplateLoader.Instance.init(pre.Extensions.folder);

export const Config = ExtensionConfigWrapper.originalSync(true);
Loading