X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/83cc752d85a910c19ffaf5c74433fbf7fa76e038..42ec7892e74f6d9d19f2f0155830565f447a861f:/src/store/collections/collection-partial-copy-actions.ts diff --git a/src/store/collections/collection-partial-copy-actions.ts b/src/store/collections/collection-partial-copy-actions.ts index 72374e65..74fa17b3 100644 --- a/src/store/collections/collection-partial-copy-actions.ts +++ b/src/store/collections/collection-partial-copy-actions.ts @@ -61,8 +61,15 @@ export const copyCollectionPartial = ({ name, description, projectUuid }: Collec manifestText: collection.manifestText, }; const newCollection = await services.collectionService.create(collectionCopy); - const paths = filterCollectionFilesBySelection(state.collectionPanelFiles, false).map(file => file.id); - await services.collectionService.deleteFiles(newCollection.uuid, paths); + const copiedFiles = await services.collectionService.files(newCollection.uuid); + const paths = filterCollectionFilesBySelection(state.collectionPanelFiles, true).map(file => file.id); + const filesToDelete = copiedFiles.map(({ id }) => id).filter(file => { + return !paths.find(path => path.indexOf(file.replace(newCollection.uuid, '')) > -1); + }); + await services.collectionService.deleteFiles( + '', + filesToDelete + ); dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'New collection created.',