From c795e19663a93c24908a7318975f820bac63164f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Aug 2022 15:08:36 +0200 Subject: Automatically rebuild native modules on ABI change --- server/lib/plugins/plugin-manager.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server/lib/plugins/plugin-manager.ts') diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index a706df1e0..a46b97fa4 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts @@ -3,6 +3,7 @@ import { createReadStream, createWriteStream } from 'fs' import { ensureDir, outputFile, readJSON } from 'fs-extra' import { basename, join } from 'path' import { decachePlugin } from '@server/helpers/decache' +import { ApplicationModel } from '@server/models/application/application' import { MOAuthTokenUser, MUser } from '@server/types/models' import { getCompleteLocale } from '@shared/core-utils' import { @@ -23,7 +24,7 @@ import { PluginModel } from '../../models/server/plugin' import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPassOptions, RegisterServerOptions } from '../../types/plugins' import { ClientHtml } from '../client-html' import { RegisterHelpers } from './register-helpers' -import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' +import { installNpmPlugin, installNpmPluginFromDisk, rebuildNativePlugins, removeNpmPlugin } from './yarn' export interface RegisteredPlugin { npmName: string @@ -384,6 +385,12 @@ export class PluginManager implements ServerHook { logger.info('Plugin %s uninstalled.', npmName) } + async rebuildNativePluginsIfNeeded () { + if (!await ApplicationModel.nodeABIChanged()) return + + return rebuildNativePlugins() + } + // ###################### Private register ###################### private async registerPluginOrTheme (plugin: PluginModel) { -- cgit v1.2.3