refactor(core): Prevent community packages queries if feature is disabled (#6728)

This commit is contained in:
Iván Ovejero 2023-07-25 10:22:32 +02:00 committed by GitHub
parent eeb49e9375
commit e1e6d4a749
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -221,6 +221,17 @@ export class Start extends BaseCommand {
await this.loadNodesAndCredentials.generateTypesForFrontend();
await UserSettings.getEncryptionKey();
// Load settings from database and set them to config.
const databaseSettings = await Db.collections.Settings.findBy({ loadOnStartup: true });
databaseSettings.forEach((setting) => {
config.set(setting.key, jsonParse(setting.value, { fallbackValue: setting.value }));
});
const areCommunityPackagesEnabled = config.getEnv('nodes.communityPackages.enabled');
if (areCommunityPackagesEnabled) {
const installedPackages = await getAllInstalledPackages();
const missingPackages = new Set<{
packageName: string;
@ -238,14 +249,6 @@ export class Start extends BaseCommand {
});
});
await UserSettings.getEncryptionKey();
// Load settings from database and set them to config.
const databaseSettings = await Db.collections.Settings.findBy({ loadOnStartup: true });
databaseSettings.forEach((setting) => {
config.set(setting.key, jsonParse(setting.value, { fallbackValue: setting.value }));
});
config.set('nodes.packagesMissing', '');
if (missingPackages.size) {
LoggerProxy.error(
@ -277,6 +280,7 @@ export class Start extends BaseCommand {
.join(' '),
);
}
}
const dbType = config.getEnv('database.type');
if (dbType === 'sqlite') {