Skip to content

Commit

Permalink
🐛 Fix plugins data path
Browse files Browse the repository at this point in the history
all the data related to plugin database should be under  //data/plugins/
share rootPath info from controller
  • Loading branch information
ManuGowda committed Aug 13, 2020
1 parent b8233e4 commit 8cfc306
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
7 changes: 4 additions & 3 deletions framework-plugins/lisk-framework-forger-plugin/src/db.ts
Expand Up @@ -26,11 +26,12 @@ import { ForgerInfo, ForgetSyncInfo } from './types';
const debug = Debug('plugin:forger:db');

export const getDBInstance = async (
dataPath: string,
rootPath: string,
dataPath = 'plugins',
dbName = 'lisk-framework-forger-plugin.db',
): Promise<KVStore> => {
const resolvedPath = dataPath.replace('~', os.homedir());
const dirPath = join(resolvedPath, dbName);
const resolvedPath = rootPath.replace('~', os.homedir());
const dirPath = join(resolvedPath, dataPath, dbName);
await ensureDir(dirPath);

return new KVStore(dirPath);
Expand Down
Expand Up @@ -29,15 +29,6 @@ export const defaultConfig = {
description:
'Explicitly allowing some identified entities access to forger plugin endpoints.',
},
dataPath: {
type: 'string',
format: 'path',
minLength: 1,
maxLength: 50,
example: '~/.lisk/plugins/data',
description:
'The data path for storing forging related information captured from application.',
},
webhook: {
type: 'array',
description: 'Third party API endpoints with configurable events to emit.',
Expand Down Expand Up @@ -105,7 +96,6 @@ export const defaultConfig = {
port: 4001,
whiteList: ['127.0.0.1'],
webhook: [],
dataPath: '~/.lisk/plugins/data',
cors: {
origin: '*',
methods: ['GET', 'POST', 'PUT'],
Expand Down
Expand Up @@ -141,7 +141,7 @@ export class ForgerPlugin extends BasePlugin {
},
options.webhook,
);
this._forgerPluginDB = await getDBInstance(options.dataPath);
this._forgerPluginDB = await getDBInstance(options.rootPath, options.dataPath);

// eslint-disable-next-line @typescript-eslint/no-misused-promises
this._channel.once('app:ready', async () => {
Expand Down
3 changes: 2 additions & 1 deletion framework-plugins/lisk-framework-forger-plugin/src/types.ts
Expand Up @@ -14,7 +14,8 @@

export interface Options {
version: string;
readonly dataPath: string;
readonly rootPath: string;
readonly dataPath?: string;
readonly webhook: ReadonlyArray<Webhook>;
readonly port: number;
readonly whiteList: ReadonlyArray<string>;
Expand Down
2 changes: 1 addition & 1 deletion framework/src/controller/controller.ts
Expand Up @@ -119,7 +119,7 @@ export class Controller {

for (const alias of Object.keys(plugins)) {
const klass = plugins[alias];
const options = pluginOptions[alias];
const options = { rootPath: this.config.rootPath, ...pluginOptions[alias] };

if (options.loadAsChildProcess) {
if (this.config.ipc.enabled) {
Expand Down

0 comments on commit 8cfc306

Please sign in to comment.