mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-18 20:50:48 +01:00
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 { ClientsFactory } from '../libs/ClientsFactory';
|
||||||
import MySQLImporter from '../libs/importers/sql/MySQLlImporter';
|
import MySQLImporter from '../libs/importers/sql/MySQLlImporter';
|
||||||
import PostgreSQLImporter from '../libs/importers/sql/PostgreSQLImporter';
|
import PostgreSQLImporter from '../libs/importers/sql/PostgreSQLImporter';
|
||||||
|
import SSHConfig from 'ssh2-promise/lib/sshConfig';
|
||||||
|
import { ImportOptions } from 'common/interfaces/importer';
|
||||||
let importer: antares.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') {
|
if (type === 'init') {
|
||||||
|
try {
|
||||||
const connection = await ClientsFactory.getClient({
|
const connection = await ClientsFactory.getClient({
|
||||||
client: options.type,
|
client: options.type,
|
||||||
params: {
|
params: {
|
||||||
@ -72,6 +82,30 @@ process.on('message', async ({ type, dbConfig, options }) => {
|
|||||||
|
|
||||||
importer.run();
|
importer.run();
|
||||||
}
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
process.send({
|
||||||
|
type: 'error',
|
||||||
|
payload: err.toString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (type === 'cancel')
|
else if (type === 'cancel')
|
||||||
importer.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…
x
Reference in New Issue
Block a user