mirror of https://github.com/Fabio286/antares.git
fix: unable to import after a failed import, fixes #515
This commit is contained in:
parent
fe9817bf31
commit
b1fbc43ab2
|
@ -6,10 +6,20 @@ import { PostgreSQLClient } from '../libs/clients/PostgreSQLClient';
|
|||
import { ClientsFactory } from '../libs/ClientsFactory';
|
||||
import MySQLImporter from '../libs/importers/sql/MySQLlImporter';
|
||||
import PostgreSQLImporter from '../libs/importers/sql/PostgreSQLImporter';
|
||||
import SSHConfig from 'ssh2-promise/lib/sshConfig';
|
||||
import { ImportOptions } from 'common/interfaces/importer';
|
||||
let importer: antares.Importer;
|
||||
|
||||
process.on('message', async ({ type, dbConfig, options }) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
process.on('message', async ({ type, dbConfig, options }: {
|
||||
type: string;
|
||||
dbConfig: mysql.ConnectionOptions & { schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean }
|
||||
| pg.ClientConfig & { schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean }
|
||||
| { databasePath: string; readonly: boolean };
|
||||
options: ImportOptions;
|
||||
}) => {
|
||||
if (type === 'init') {
|
||||
try {
|
||||
const connection = await ClientsFactory.getClient({
|
||||
client: options.type,
|
||||
params: {
|
||||
|
@ -72,6 +82,30 @@ process.on('message', async ({ type, dbConfig, options }) => {
|
|||
|
||||
importer.run();
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (type === 'cancel')
|
||||
importer.cancel();
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error(err);
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error(err);
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue