}
async deleteFiles(collectionUuid: string, filePaths: string[]) {
- for (const path of filePaths) {
- const splittedPath = path.split('/');
- if (collectionUuid) {
- await this.webdavClient.delete(`c=${collectionUuid}/${splittedPath[1]}`);
- } else {
+ const sortedUniquePaths = Array.from(new Set(filePaths))
+ .sort((a, b) => b.length - a.length);
+
+ for (const path of sortedUniquePaths) {
+ if (path.indexOf(collectionUuid) === -1) {
await this.webdavClient.delete(`c=${collectionUuid}${path}`);
+ } else {
+ await this.webdavClient.delete(`c=${path}`);
}
}
}
dispatch(snackbarActions.OPEN_SNACKBAR({
message: `Error getting file list: ${e.errors[0]}`,
hideDuration: 2000,
- kind: SnackbarKind.ERROR }));
+ kind: SnackbarKind.ERROR
+ }));
});
};
dispatch<any>(loadCollectionPanel(currentCollection.uuid, true));
dispatch(dialogActions.CLOSE_DIALOG({ id: RENAME_FILE_DIALOG }));
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 }));
- }).catch (e => {
+ }).catch(e => {
const errors: FormErrors<RenameFileDialogData, string> = {
path: `Could not rename the file: ${e.responseText}`
};