diff --git a/src/main/libs/exporters/BaseExporter.js b/src/main/libs/exporters/BaseExporter.js index 50d35a07..2870f96f 100644 --- a/src/main/libs/exporters/BaseExporter.js +++ b/src/main/libs/exporters/BaseExporter.js @@ -1,4 +1,5 @@ import fs from 'fs'; +import { createGzip } from 'zlib'; import path from 'path'; import EventEmitter from 'events'; @@ -8,12 +9,19 @@ export class BaseExporter extends EventEmitter { this._tables = tables; this._options = options; this._isCancelled = false; - this._outputStream = fs.createWriteStream(this._options.outputFile, { - flags: 'w' - }); + this._outputFileStream = fs.createWriteStream(this._options.outputFile, { flags: 'w' }); + this._processedStream = null; this._state = {}; - this._outputStream.once('error', err => { + if (this._options.outputFormat === 'sql.zip') { + const outputZipStream = createGzip(); + outputZipStream.pipe(this._outputFileStream); + this._processedStream = outputZipStream; + } + else + this._processedStream = this._outputFileStream; + + this._processedStream.once('error', err => { this._isCancelled = true; this.emit('error', err); }); @@ -29,7 +37,7 @@ export class BaseExporter extends EventEmitter { throw err; } finally { - this._outputStream.end(); + this._processedStream.end(); this.emit('end'); } } @@ -68,7 +76,7 @@ export class BaseExporter extends EventEmitter { const fileName = path.basename(this._options.outputFile); this.emit('error', `The file ${fileName} is not accessible`); } - this._outputStream.write(data); + this._processedStream.write(data); } dump () { diff --git a/src/renderer/components/ModalExportSchema.vue b/src/renderer/components/ModalExportSchema.vue index c7a5d02a..6b2c8810 100644 --- a/src/renderer/components/ModalExportSchema.vue +++ b/src/renderer/components/ModalExportSchema.vue @@ -181,11 +181,10 @@
-

+

{{ $t('word.options') }} -
- {{ $t('word.includes') }}: - + + {{ $t('word.includes') }}: -
+
{{ $t('message.newInserStmtEvery') }}:
@@ -217,6 +216,22 @@
+ +
+ {{ $t('message.ourputFormat') }}: +
+
+
+ +
+
@@ -275,6 +290,7 @@ export default { tables: [], options: { includes: {}, + outputFormat: 'sql', sqlInsertAfter: 250, sqlInsertDivider: 'bytes' }, @@ -299,7 +315,7 @@ export default { }, filename () { const date = moment().format('YYYY-MM-DD'); - return `${this.selectedSchema}_${date}.sql`; + return `${this.selectedSchema}_${date}.${this.options.outputFormat}`; }, dumpFilePath () { return `${this.basePath}/${this.filename}`; diff --git a/src/renderer/i18n/en-US.js b/src/renderer/i18n/en-US.js index e7808f88..3a6fb615 100644 --- a/src/renderer/i18n/en-US.js +++ b/src/renderer/i18n/en-US.js @@ -283,7 +283,10 @@ module.exports = { manualCommit: 'Manual commit', actionSuccessful: '{action} successful', importQueryErrors: 'Warning: {n} error has accurrend | Warning: {n} errors occurred', - executedQueries: '{n} query executed | {n} queries executed' + executedQueries: '{n} query executed | {n} queries executed', + ourputFormat: 'Output format', + singleFile: 'Single {ext} file', + zipCompressedFile: 'ZIP compressed {ext} file' }, faker: { address: 'Address',