From 7e90ce621ec6b5831c2dad978d61cc66fb5e3d57 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Mon, 5 Aug 2024 09:14:41 +0200 Subject: [PATCH] Fix readAllBytes with http files (#5202) Signed-off-by: Paolo Di Tommaso --- .../file/http/XFileSystemProvider.groovy | 2 +- .../nextflow/file/http/HttpFilesTests.groovy | 24 ++++++------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/modules/nf-httpfs/src/main/nextflow/file/http/XFileSystemProvider.groovy b/modules/nf-httpfs/src/main/nextflow/file/http/XFileSystemProvider.groovy index b3f445606f..e673a930c1 100644 --- a/modules/nf-httpfs/src/main/nextflow/file/http/XFileSystemProvider.groovy +++ b/modules/nf-httpfs/src/main/nextflow/file/http/XFileSystemProvider.groovy @@ -255,7 +255,7 @@ abstract class XFileSystemProvider extends FileSystemProvider { int read(ByteBuffer buffer) throws IOException { def data=0 int len=0 - while( len0 lines[0].startsWith('') - + } def 'should check file properties' () { @@ -190,27 +190,17 @@ class HttpFilesTests extends Specification { @IgnoreIf({System.getenv('NXF_SMOKE')}) def 'should read lines' () { given: - def path = Paths.get(new URI('ftp://ftp.ncbi.nlm.nih.gov/robots.txt')) - + def uri = new URI('http://www.nextflow.io/index.html') when: - def lines = Files.readAllLines(path, Charset.forName('UTF-8')) + def path = Paths.get(uri) then: - lines[0] == 'User-agent: *' - lines[1] == 'Disallow: /' - } - - @IgnoreIf({System.getenv('NXF_SMOKE')}) - def 'should read all bytes' ( ) { - given: - def path = Paths.get(new URI('ftp://ftp.ncbi.nlm.nih.gov/robots.txt')) + path instanceof XPath when: - def bytes = Files.readAllBytes(path) - def lines = new String(bytes).readLines() + def str = new String(Files.readAllBytes(path), Charset.forName('UTF-8')) then: - lines[0] == 'User-agent: *' - lines[1] == 'Disallow: /' - + str.size()>0 + str.startsWith('') } def 'should read with a newByteChannel' () {