Skip to content

Commit 64dbafe

Browse files
jeanp413Benjamin Pasero
andauthored
Better experience for replacing folders in web upload (microsoft#99601)
* Fixes microsoft#99074 * properly await Co-authored-by: Benjamin Pasero <benjpas@microsoft.com>
1 parent 3ddf7a8 commit 64dbafe

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

src/vs/workbench/contrib/files/browser/views/explorerViewer.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,18 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
984984
title: localize('uploadingFiles', "Uploading")
985985
}, async progress => {
986986
for (let entry of entries) {
987+
988+
// Confirm overwrite as needed
989+
if (target && entry.name && target.getChild(entry.name)) {
990+
const { confirmed } = await this.dialogService.confirm(getFileOverwriteConfirm(entry.name));
991+
if (!confirmed) {
992+
continue;
993+
}
994+
995+
await this.workingCopyFileService.delete(joinPath(target.resource, entry.name), { recursive: true });
996+
}
997+
998+
// Upload entry
987999
const result = await this.doUploadWebFileEntry(entry, target.resource, target, progress, operation, cts.token);
9881000
if (result) {
9891001
results.push(result);
@@ -1008,20 +1020,6 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
10081020
return undefined;
10091021
}
10101022

1011-
const resource = joinPath(parentResource, entry.name);
1012-
1013-
// Confirm overwrite as needed
1014-
if (target && target.getChild(entry.name)) {
1015-
const { confirmed } = await this.dialogService.confirm(getFileOverwriteConfirm(resource.path));
1016-
if (!confirmed) {
1017-
return undefined;
1018-
}
1019-
}
1020-
1021-
if (token.isCancellationRequested) {
1022-
return undefined;
1023-
}
1024-
10251023
// Report progress
10261024
let totalBytesUploaded = 0;
10271025
const reportProgress = (fileSize: number, bytesUploaded: number): void => {
@@ -1044,6 +1042,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
10441042
reportProgress(0, 0);
10451043

10461044
// Handle file upload
1045+
const resource = joinPath(parentResource, entry.name);
10471046
if (entry.isFile) {
10481047
const file = await new Promise<File>((resolve, reject) => entry.file(resolve, reject));
10491048

0 commit comments

Comments
 (0)