From adea04e254bbabb138d404b934e2cd5310d1477d Mon Sep 17 00:00:00 2001 From: Ronen Date: Fri, 7 Feb 2025 15:47:20 -0500 Subject: [PATCH] fix: All Annotations AWS CLI command (#1593) --- .../components/Download/AWSDownloadTab.tsx | 24 +++++++++++++++---- .../downloadDialog/downloadDialogActor.ts | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/frontend/packages/data-portal/app/components/Download/AWSDownloadTab.tsx b/frontend/packages/data-portal/app/components/Download/AWSDownloadTab.tsx index 1859d63c8..f835a7e2b 100644 --- a/frontend/packages/data-portal/app/components/Download/AWSDownloadTab.tsx +++ b/frontend/packages/data-portal/app/components/Download/AWSDownloadTab.tsx @@ -11,15 +11,28 @@ import { DownloadConfig } from 'app/types/download' import { SelectSaveDestination } from './SelectSaveDestination' +const AWS_S3_BASE_COMMAND = 'aws s3 --no-sign-request' + export function getAwsCommand({ s3Path, s3Command, + isAllAnnotations = false, }: { s3Path: string | undefined s3Command: 'cp' | 'sync' + isAllAnnotations?: boolean }): string { - const destinationPath = s3Path?.replace(/\/$/, '').split('/').pop() - return `aws s3 --no-sign-request ${s3Command} ${s3Path} ${destinationPath}` + const originPath = s3Path?.replace(/\/$/, '') + const destinationPath = originPath?.split('/').pop() + + if (isAllAnnotations) { + const basePathMatch = s3Path?.match(/^([^/]+\/.*?\/Reconstructions)/) + const basePath = basePathMatch ? basePathMatch[1] : '' + + return `${AWS_S3_BASE_COMMAND} ${s3Command} ${basePath}/ Annotations --exclude "*" --include "*/Annotations/*"` + } + + return `${AWS_S3_BASE_COMMAND} ${s3Command} ${originPath} ${destinationPath}` } export function AWSDownloadTab() { @@ -28,21 +41,22 @@ export function AWSDownloadTab() { const { logPlausibleCopyEvent } = useLogPlausibleCopyEvent() const location = useLocation() const { downloadConfig, fileFormat } = useDownloadModalQueryParamState() + const isAllAnnotations = downloadConfig === DownloadConfig.AllAnnotations const s3Command = match({ pathname: location.pathname, - downloadConfig, + isAllAnnotations, fileFormat, }) .with( { pathname: P.string.includes('/datasets') }, - { downloadConfig: DownloadConfig.AllAnnotations }, + { isAllAnnotations: true }, { fileFormat: 'zarr' }, () => 'sync' as const, ) .otherwise(() => 'cp' as const) - const awsCommand = getAwsCommand({ s3Path, s3Command }) + const awsCommand = getAwsCommand({ s3Path, s3Command, isAllAnnotations }) return (
diff --git a/frontend/packages/data-portal/e2e/pageObjects/downloadDialog/downloadDialogActor.ts b/frontend/packages/data-portal/e2e/pageObjects/downloadDialog/downloadDialogActor.ts index 1affe9183..0ed48a91b 100644 --- a/frontend/packages/data-portal/e2e/pageObjects/downloadDialog/downloadDialogActor.ts +++ b/frontend/packages/data-portal/e2e/pageObjects/downloadDialog/downloadDialogActor.ts @@ -348,6 +348,7 @@ export class DownloadDialogActor { const expectedCommand = getAwsCommand({ s3Path: s3Prefix, s3Command: 'sync', + isAllAnnotations: true, }) expect(clipboardValue).toBe(expectedCommand) }