Skip to content

Commit 25a234d

Browse files
authored
fix(ContentNavigator): added name checking for duplicates on drag and drop (#1665)
* feat(ContentNavigator): added name checking for duplicates on drag and drop Signed-off-by: Kishan Patel <[email protected]> * fix(ContentNavigator): changed to server side handling for drag and drop on restserveradapter Signed-off-by: Kishan Patel <[email protected]> --------- Signed-off-by: Kishan Patel <[email protected]>
1 parent e8c5a1e commit 25a234d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

client/src/components/ContentNavigator/ContentDataProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,14 @@ class ContentDataProvider
717717
path: string,
718718
displayErrorMessages: boolean = true,
719719
): Promise<boolean> {
720-
const folder = await this.model.createFolder(target, basename(path));
720+
const folderName = basename(path);
721+
const folder = await this.model.createFolder(target, folderName);
721722
let success = true;
722723
if (!folder) {
723724
displayErrorMessages &&
724725
window.showErrorMessage(
725726
l10n.t(Messages.FileDropError, {
726-
name: basename(path),
727+
name: folderName,
727728
}),
728729
);
729730

client/src/connection/rest/RestServerAdapter.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,17 @@ class RestServerAdapter implements ContentAdapter {
447447
},
448448
};
449449

450-
const response =
451-
await this.fileSystemApi.updateFileOrDirectoryOnSystem(params);
452-
delete this.fileMetadataMap[currentFilePath];
453-
this.updateFileMetadata(newFilePath, response);
450+
try {
451+
const response =
452+
await this.fileSystemApi.updateFileOrDirectoryOnSystem(params);
453+
delete this.fileMetadataMap[currentFilePath];
454+
this.updateFileMetadata(newFilePath, response);
454455

455-
return this.filePropertiesToContentItem(response.data).vscUri;
456+
return this.filePropertiesToContentItem(response.data).vscUri;
457+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
458+
} catch (error) {
459+
return;
460+
}
456461
}
457462

458463
public async renameItem(

0 commit comments

Comments
 (0)