diff --git a/packages/api/src/shell/copyStream.js b/packages/api/src/shell/copyStream.js index c6471619f..edf9bbe52 100644 --- a/packages/api/src/shell/copyStream.js +++ b/packages/api/src/shell/copyStream.js @@ -1,8 +1,25 @@ const EnsureStreamHeaderStream = require('../utility/EnsureStreamHeaderStream'); const ColumnMapTransformStream = require('../utility/ColumnMapTransformStream'); const streamPipeline = require('../utility/streamPipeline'); -const { getLogger, extractErrorLogData } = require('dbgate-tools'); +const { getLogger, extractErrorLogData, RowProgressReporter } = require('dbgate-tools'); const logger = getLogger('copyStream'); +const stream = require('stream'); + +class ReportingTransform extends stream.Transform { + constructor(reporter, options = {}) { + super({ ...options, objectMode: true }); + this.reporter = reporter; + } + _transform(chunk, encoding, callback) { + this.reporter.add(1); + this.push(chunk); + callback(); + } + _flush(callback) { + this.reporter.finish(); + callback(); + } +} /** * Copies reader to writer. Used for import, export tables and transfer data between tables @@ -23,6 +40,11 @@ async function copyStream(input, output, options) { } const transforms = []; + + if (progressName) { + const reporter = new RowProgressReporter(progressName, 'readRowCount'); + transforms.push(new ReportingTransform(reporter)); + } if (columns) { transforms.push(new ColumnMapTransformStream(columns)); } diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index b446d0fd9..48c137d11 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -25,3 +25,4 @@ export * from './detectSqlFilterBehaviour'; export * from './filterBehaviours'; export * from './schemaInfoTools'; export * from './dbKeysLoader'; +export * from './rowProgressReporter'; \ No newline at end of file diff --git a/packages/web/src/impexp/ImportExportConfigurator.svelte b/packages/web/src/impexp/ImportExportConfigurator.svelte index 5eb49fdd1..0086f15e7 100644 --- a/packages/web/src/impexp/ImportExportConfigurator.svelte +++ b/packages/web/src/impexp/ImportExportConfigurator.svelte @@ -307,7 +307,9 @@ {#if progressHolder[row]?.status == 'running'} {#if progressHolder[row]?.writtenRowCount} - {progressHolder[row]?.writtenRowCount} rows written + {progressHolder[row]?.writtenRowCount} rows writtem + {:else if progressHolder[row]?.readRowCount} + {progressHolder[row]?.readRowCount} rows read {:else} Running {/if} @@ -325,6 +327,8 @@ {#if progressHolder[row]?.writtenRowCount} {progressHolder[row]?.writtenRowCount} rows written + {:else if progressHolder[row]?.readRowCount} + {progressHolder[row]?.readRowCount} rows read {:else} Done {/if}