Skip to content

Commit a2cebf8

Browse files
committed
refactor(backend): migrate FileCacheService
FileCacheService was still a legacy service extending AdvancedBase. This commit changes it to extend BaseService and implement the lifecycle methods consistent with other services. This is a prerequisite for moving write_overwrite which needs to import the service via `extension.import` (not possible for legacy services) so that it may invalidate file cache when a file is written to.
1 parent bd81c53 commit a2cebf8

File tree

3 files changed

+81
-88
lines changed

3 files changed

+81
-88
lines changed

src/backend/src/CoreModule.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,19 @@ const install = async ({ context, services, app, useapi, modapi }) => {
433433

434434
const { PermissionShortcutService } = require('./services/auth/PermissionShortcutService');
435435
services.registerService('permission-shortcut', PermissionShortcutService);
436+
437+
const { FileCacheService } = require('./services/file-cache/FileCacheService');
438+
services.registerService('file-cache', FileCacheService);
436439
};
437440

438441
const install_legacy = async ({ services }) => {
439442
const { OperationTraceService } = require('./services/OperationTraceService');
440443
const { ClientOperationService } = require('./services/ClientOperationService');
441444
const { EngPortalService } = require('./services/EngPortalService');
442-
const { FileCacheService } = require('./services/file-cache/FileCacheService');
443445

444446
// === Services which do not yet extend BaseService ===
445447
// services.registerService('filesystem', FilesystemService);
446448
services.registerService('operationTrace', OperationTraceService);
447-
services.registerService('file-cache', FileCacheService);
448449
services.registerService('client-operation', ClientOperationService);
449450
services.registerService('engineering-portal', EngPortalService);
450451

src/backend/src/services/CommandService.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,18 @@ class CommandService extends BaseService {
127127
}
128128

129129
registerCommands(serviceName, commands) {
130-
if ( ! this.log ) process.exit(1);
130+
if ( ! this.log ) {
131+
/* eslint-disable */
132+
console.error(
133+
'CommandService.registerCommands was called before a logger ' +
134+
'was initialied. This happens when calling registerCommands ' +
135+
'in the "construct" phase instead of the "init" phase. If ' +
136+
'you are migrating a legacy service that does not extend ' +
137+
'BaseService, maybe the _construct hook is calling init()'
138+
);
139+
/* eslint-enable */
140+
process.exit(1);
141+
}
131142
for (const command of commands) {
132143
this.log.debug(`registering command ${serviceName}:${command.id}`);
133144
this.commands_.push(new Command({

0 commit comments

Comments
 (0)