From 19a72c402495e72df0140c6af05d299330fa5ba9 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Mon, 31 Jul 2023 14:58:59 +0200 Subject: [PATCH] Fix glob resolution for remove files Signed-off-by: Paolo Di Tommaso --- .../nextflow/src/main/groovy/nextflow/Nextflow.groovy | 4 +++- .../test/nextflow/file/FilePatternSplitterTest.groovy | 3 ++- .../nf-amazon/src/test/nextflow/S3NextflowTest.groovy | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/Nextflow.groovy b/modules/nextflow/src/main/groovy/nextflow/Nextflow.groovy index 24012743ac..dd1b03f8e8 100644 --- a/modules/nextflow/src/main/groovy/nextflow/Nextflow.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/Nextflow.groovy @@ -18,6 +18,7 @@ package nextflow import static nextflow.file.FileHelper.* +import java.nio.file.FileSystem import java.nio.file.Files import java.nio.file.NoSuchFileException import java.nio.file.Path @@ -60,7 +61,8 @@ class Nextflow { static private fileNamePattern( FilePatternSplitter splitter, Map opts ) { final scheme = splitter.scheme - final folder = toCanonicalPath(splitter.parent) + final target = scheme ? "$scheme://$splitter.parent" : splitter.parent + final folder = toCanonicalPath(target) final pattern = splitter.fileName if( opts == null ) opts = [:] diff --git a/modules/nf-commons/src/test/nextflow/file/FilePatternSplitterTest.groovy b/modules/nf-commons/src/test/nextflow/file/FilePatternSplitterTest.groovy index 002e517cbf..10173f9804 100644 --- a/modules/nf-commons/src/test/nextflow/file/FilePatternSplitterTest.groovy +++ b/modules/nf-commons/src/test/nextflow/file/FilePatternSplitterTest.groovy @@ -112,7 +112,8 @@ class FilePatternSplitterTest extends Specification { 'test/data/file[a-b]' | 'test/data/' | 'file[a-b]' | null 'test/data[a-b]/file' | 'test/' | 'data[a-b]/file' | null '/some/path\\[a-b\\]/data{a,b}/file\\?' | '/some/path[a-b]/'| 'data{a,b}/file\\?' | null - + 's3://foo/bar/*' | 'foo/bar/' | '*' | 's3' + 's3://foo/bar/file.txt' | 'foo/bar/' | 'file.txt' | 's3' } def 'should strip glob escape chars' () { diff --git a/plugins/nf-amazon/src/test/nextflow/S3NextflowTest.groovy b/plugins/nf-amazon/src/test/nextflow/S3NextflowTest.groovy index ce62bd1140..dddfd6be8c 100644 --- a/plugins/nf-amazon/src/test/nextflow/S3NextflowTest.groovy +++ b/plugins/nf-amazon/src/test/nextflow/S3NextflowTest.groovy @@ -19,6 +19,8 @@ package nextflow import java.nio.file.Paths +import spock.lang.IgnoreIf +import spock.lang.Requires import spock.lang.Specification /** * @@ -46,4 +48,13 @@ class S3NextflowTest extends Specification { SysEnv.pop() } + @IgnoreIf({System.getenv('NXF_SMOKE')}) + @Requires({System.getenv('AWS_S3FS_ACCESS_KEY') && System.getenv('AWS_S3FS_SECRET_KEY')}) + def 'should resolve list of files' () { + when: + def result = Nextflow.files('s3://ngi-igenomes/*') + then: + result.size() == 3 + } + }