Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/cmds/files_cmds/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions test/unit/commands/file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading