Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better experience for replacing folders in web upload #99601

Merged
merged 3 commits into from
Jun 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,18 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
title: localize('uploadingFiles', "Uploading")
}, async progress => {
for (let entry of entries) {

// Confirm overwrite as needed
if (target && entry.name && target.getChild(entry.name)) {
const { confirmed } = await this.dialogService.confirm(getFileOverwriteConfirm(entry.name));
if (!confirmed) {
continue;
}

await this.workingCopyFileService.delete(joinPath(target.resource, entry.name), { recursive: true });
}

// Upload entry
const result = await this.doUploadWebFileEntry(entry, target.resource, target, progress, operation, cts.token);
if (result) {
results.push(result);
Expand All @@ -1008,20 +1020,6 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
return undefined;
}

const resource = joinPath(parentResource, entry.name);

// Confirm overwrite as needed
if (target && target.getChild(entry.name)) {
const { confirmed } = await this.dialogService.confirm(getFileOverwriteConfirm(resource.path));
if (!confirmed) {
return undefined;
}
}

if (token.isCancellationRequested) {
return undefined;
}

// Report progress
let totalBytesUploaded = 0;
const reportProgress = (fileSize: number, bytesUploaded: number): void => {
Expand All @@ -1044,6 +1042,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
reportProgress(0, 0);

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

Expand Down