From 5518f9e4e610e1780cf992840aa801f9b551dfe4 Mon Sep 17 00:00:00 2001 From: Ryan Ratcliff Date: Tue, 10 Mar 2026 10:43:58 -0400 Subject: [PATCH] fix: use full path as prefix for recursive files download Made-with: Cursor --- lib/cmds/files_cmds/download.js | 4 +++- test/unit/commands/file.test.js | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/cmds/files_cmds/download.js b/lib/cmds/files_cmds/download.js index b49c713..5757d43 100644 --- a/lib/cmds/files_cmds/download.js +++ b/lib/cmds/files_cmds/download.js @@ -34,7 +34,9 @@ exports.builder = yargs => { exports.handler = async argv => { if (argv.recursive) { - const [datasetId, prefix] = argv.source.split('/'); + const parts = argv.source.split('/').filter(Boolean); + const datasetId = parts[0]; + const prefix = parts.length > 1 ? parts.slice(1).join('/') : ''; const opts = { datasetId, diff --git a/test/unit/commands/file.test.js b/test/unit/commands/file.test.js index 4ff5d94..4c58219 100644 --- a/test/unit/commands/file.test.js +++ b/test/unit/commands/file.test.js @@ -250,6 +250,31 @@ test.serial.cb('The "files-download" command should download a set of files from .parse('download projectId/prefix /dir -r'); }); +test.serial.cb('The "files-download" command should use full path as prefix for recursive download', t => { + listStub.onFirstCall().returns({ + data: { + items: [ + { + id: '1', + name: 'genomic-archive/snp-array-vcf-Build38/sample.vcf.gz' + } + ] + } + }); + + callback = () => { + t.is(listStub.callCount, 1); + t.is(listStub.getCall(0).args[1], '/v1/files?datasetId=projectId&pageSize=1000&name=genomic-archive%2Fsnp-array-vcf-Build38'); + t.end(); + }; + + t.context.deleteFileStub = t.context.sandbox.stub(fs, 'unlinkSync').callsFake(callback); + t.context.copyFileStub = t.context.sandbox.stub(fs, 'copyFileSync').callsFake(callback); + + yargs.command(download) + .parse('download projectId/genomic-archive/snp-array-vcf-Build38/ . -r'); +}); + test.serial.cb('The "files-mv" command should move a set of files from a project', t => { patchStub.returns({}); listStub.onFirstCall().returns({