mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-13 02:00:36 +01:00
Merge branch 'develop' into flatpak-experiments
This commit is contained in:
commit
8774dd44e6
@ -205,11 +205,6 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
|
||||
return new Promise((resolve/*, reject */) => {
|
||||
(async () => {
|
||||
// if (isFlatpak) {
|
||||
// resolve({ status: 'error', response: 'Temporarily unavailable on Flatpak' });
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (fs.existsSync(rest.outputFile)) { // If file exists ask for replace
|
||||
const result = await dialog.showMessageBox({
|
||||
type: 'warning',
|
||||
@ -242,10 +237,21 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
},
|
||||
tables,
|
||||
options: rest
|
||||
});
|
||||
}));
|
||||
|
||||
// Exporter message listener
|
||||
exporter.on('message', ({ type, payload }: workers.WorkerIpcMessage) => {
|
||||
exporter.stdout.on('data', (buff: Buffer) => {
|
||||
let message;
|
||||
try { // Ignore non-JSON data (console.log output)
|
||||
message = JSON.parse(buff.toString());
|
||||
}
|
||||
catch (_) {
|
||||
if (process.env.NODE_ENV === 'development') console.log('EXPORTER:', buff.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
const { type, payload } = message as workers.WorkerIpcMessage;
|
||||
|
||||
switch (type) {
|
||||
case 'export-progress':
|
||||
event.sender.send('export-progress', payload);
|
||||
@ -270,7 +276,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
}
|
||||
});
|
||||
|
||||
exporter.on('exit', code => {
|
||||
exporter.on('close', code => {
|
||||
exporter = null;
|
||||
resolve({ status: 'error', response: `Operation ended with code: ${code}` });
|
||||
});
|
||||
@ -322,10 +328,21 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
type: 'init',
|
||||
dbConfig,
|
||||
options
|
||||
});
|
||||
}));
|
||||
|
||||
// Importer message listener
|
||||
importer.on('message', ({ type, payload }: workers.WorkerIpcMessage) => {
|
||||
importer.stdout.on('data', (buff: Buffer) => {
|
||||
let message;
|
||||
try { // Ignore non-JSON data (console.log output)
|
||||
message = JSON.parse(buff.toString());
|
||||
}
|
||||
catch (_) {
|
||||
if (process.env.NODE_ENV === 'development') console.log('IMPORTER:', buff.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
const { type, payload } = message as workers.WorkerIpcMessage;
|
||||
|
||||
switch (type) {
|
||||
case 'import-progress':
|
||||
event.sender.send('import-progress', payload);
|
||||
@ -353,7 +370,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
}
|
||||
});
|
||||
|
||||
importer.on('exit', code => {
|
||||
importer.on('close', code => {
|
||||
importer = null;
|
||||
resolve({ status: 'error', response: `Operation ended with code: ${code}` });
|
||||
});
|
||||
|
@ -33,8 +33,8 @@ export default class MySQLImporter extends BaseImporter {
|
||||
parser.on('error', reject);
|
||||
|
||||
parser.on('close', async () => {
|
||||
console.log('TOTAL QUERIES', queryCount);
|
||||
console.log('import end');
|
||||
// console.log('TOTAL QUERIES', queryCount);
|
||||
// console.log('import end');
|
||||
resolve();
|
||||
});
|
||||
|
||||
|
@ -33,8 +33,8 @@ export default class PostgreSQLImporter extends BaseImporter {
|
||||
parser.on('error', reject);
|
||||
|
||||
parser.on('close', async () => {
|
||||
console.log('TOTAL QUERIES', queryCount);
|
||||
console.log('import end');
|
||||
// console.log('TOTAL QUERIES', queryCount);
|
||||
// console.log('import end');
|
||||
resolve();
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,7 @@ import PostgreSQLExporter from '../libs/exporters/sql/PostgreSQLExporter';
|
||||
let exporter: antares.Exporter;
|
||||
|
||||
log.transports.file.fileName = 'workers.log';
|
||||
log.transports.console = null;
|
||||
log.errorHandler.startCatching();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@ -38,7 +39,7 @@ const exportHandler = async (data: any) => {
|
||||
parentPort.postMessage({
|
||||
type: 'error',
|
||||
payload: `"${client.name}" exporter not aviable`
|
||||
});
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -47,7 +48,7 @@ const exportHandler = async (data: any) => {
|
||||
parentPort.postMessage({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
exporter.once('end', () => {
|
||||
@ -55,7 +56,6 @@ const exportHandler = async (data: any) => {
|
||||
type: 'end',
|
||||
payload: { cancelled: exporter.isCancelled }
|
||||
});
|
||||
connection.destroy();
|
||||
});
|
||||
|
||||
exporter.once('cancel', () => {
|
||||
@ -67,7 +67,7 @@ const exportHandler = async (data: any) => {
|
||||
parentPort.postMessage({
|
||||
type: 'export-progress',
|
||||
payload: state
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
exporter.run();
|
||||
@ -77,7 +77,7 @@ const exportHandler = async (data: any) => {
|
||||
parentPort.postMessage({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
else if (type === 'cancel')
|
||||
|
@ -1,6 +1,4 @@
|
||||
import SSHConfig from '@fabio286/ssh2-promise/lib/sshConfig';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { ImportOptions } from 'common/interfaces/importer';
|
||||
import * as log from 'electron-log/main';
|
||||
import * as mysql from 'mysql2';
|
||||
import * as pg from 'pg';
|
||||
@ -14,6 +12,7 @@ import PostgreSQLImporter from '../libs/importers/sql/PostgreSQLImporter';
|
||||
let importer: antares.Importer;
|
||||
|
||||
log.transports.file.fileName = 'workers.log';
|
||||
log.transports.console = null;
|
||||
log.errorHandler.startCatching();
|
||||
|
||||
const importHandler = async (data: {
|
||||
@ -49,7 +48,7 @@ const importHandler = async (data: {
|
||||
parentPort.postMessage({
|
||||
type: 'error',
|
||||
payload: `"${options.type}" importer not aviable`
|
||||
});
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -58,14 +57,14 @@ const importHandler = async (data: {
|
||||
parentPort.postMessage({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
importer.once('end', () => {
|
||||
parentPort.postMessage({
|
||||
type: 'end',
|
||||
payload: { cancelled: importer.isCancelled }
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
importer.once('cancel', () => {
|
||||
@ -76,14 +75,14 @@ const importHandler = async (data: {
|
||||
parentPort.postMessage({
|
||||
type: 'import-progress',
|
||||
payload: state
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
importer.on('query-error', state => {
|
||||
parentPort.postMessage({
|
||||
type: 'query-error',
|
||||
payload: state
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
importer.run();
|
||||
@ -93,7 +92,7 @@ const importHandler = async (data: {
|
||||
parentPort.postMessage({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
else if (type === 'cancel')
|
||||
|
Loading…
x
Reference in New Issue
Block a user