From 9e75a3f98477aff0ddcc17f8994c6650c8a26c5f Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 3 Jun 2020 17:17:07 +0200 Subject: [PATCH] web - change progress to indicate number of files --- .../contrib/files/browser/views/explorerViewer.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index dc8cfdc1a42..7faca4e060e 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -974,6 +974,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { const results: { isFile: boolean, resource: URI }[] = []; const cts = new CancellationTokenSource(); + const operation = { total: entries.length, worked: 0 }; // Start upload and report progress globally const uploadPromise = this.progressService.withProgress({ @@ -983,7 +984,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { title: localize('uploadingFiles', "Uploading") }, async progress => { for (let entry of entries) { - const result = await this.doUploadWebFileEntry(entry, target.resource, target, progress, cts.token); + const result = await this.doUploadWebFileEntry(entry, target.resource, target, progress, operation, cts.token); if (result) { results.push(result); } @@ -1002,7 +1003,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } } - private async doUploadWebFileEntry(entry: IWebkitDataTransferItemEntry, parentResource: URI, target: ExplorerItem | undefined, progress: IProgress, token: CancellationToken): Promise<{ isFile: boolean, resource: URI } | undefined> { + private async doUploadWebFileEntry(entry: IWebkitDataTransferItemEntry, parentResource: URI, target: ExplorerItem | undefined, progress: IProgress, operation: { total: number; worked: number; }, token: CancellationToken): Promise<{ isFile: boolean, resource: URI } | undefined> { if (token.isCancellationRequested || !entry.name || (!entry.isFile && !entry.isDirectory)) { return undefined; } @@ -1022,7 +1023,8 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } // Report progress - progress.report({ message: entry.name }); + operation.worked++; + progress.report({ message: localize('uploadProgress', "{0} of {1} files", operation.worked, operation.total) }); // Handle file upload if (entry.isFile) { @@ -1068,9 +1070,13 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } } while (!done); + // Update operation total based on new counts + operation.total += childEntries.length; + + // Upload all entries as files to target const folderTarget = target && target.getChild(entry.name) || undefined; for (let childEntry of childEntries) { - await this.doUploadWebFileEntry(childEntry, resource, folderTarget, progress, token); + await this.doUploadWebFileEntry(childEntry, resource, folderTarget, progress, operation, token); } return { isFile: false, resource };