Skip to content

Commit

Permalink
handle single-slash URIs #PostelsLaw
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Jan 26, 2024
1 parent 468384c commit cb59d97
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
private Map<Path,BasicFileAttributes> attributesCache = [:]

static QuiltPath asQuiltPath(Path path) {
if (path !in QuiltPath) {
String pathClassName = path?.class?.name ?: '-'
throw new IllegalArgumentException(
"Not a valid Quilt blob storage path object: `${path}` [${pathClassName}]"
)
println("asQuiltPath.path: ${path}")
if (path in QuiltPath) {
return (QuiltPath)path
}
String pathString = path?.toString() ?: '-'
println("asQuiltPath.pathString: ${pathString}")
if (pathString.startsWith(QuiltParser.SCHEME + ':/')) {
QuiltPath qPath = QuiltPathFactory.parse(pathString)
println("asQuiltPath.qPath: ${qPath}")
return qPath
}
return (QuiltPath)path
String pathClassName = path?.class?.name ?: '-'
throw new IllegalArgumentException(
"Not a valid Quilt blob storage path object: `${path}` [${pathClassName}]"
)
}

static QuiltFileSystem getQuiltFilesystem(Path path) {
Expand Down Expand Up @@ -108,6 +116,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
void download(Path remoteFile, Path localDestination, CopyOption... options) throws IOException {
log.debug "QuiltFileSystemProvider.download: ${remoteFile} -> ${localDestination}"
QuiltPath qPath = asQuiltPath(remoteFile)
println("QuiltFileSystemProvider.download: ${qPath}")
Path proxy = qPath.localPath()
QuiltPackage pkg = qPath.pkg()
String pathName = pkg.parsed.getPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ class QuiltPathFactory extends FileSystemPathFactory {

@Override
protected Path parseUri(String uriString) {
if (!uriString.startsWith(QuiltParser.PREFIX)) {
println('parseUri.uriString: ' + uriString)
if (!uriString.startsWith(QuiltParser.SCHEME)) {
return null
}
final uri = new URI(uriString)
String[] split = uriString.split('/')
println('parseUri.split: ' + split)
String newString = (split[1] == '') ? uriString : uriString.replaceFirst(/\/+/, '//')
println('parseUri.newString: ' + newString)
final uri = new URI(newString)
println('parseUri.uri: ' + uri)
return FileHelper.getOrCreateFileSystemFor(uri).provider().getPath(uri)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package nextflow.quilt.nio
import nextflow.quilt.QuiltSpecification
import groovy.transform.CompileDynamic
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class QuiltPathFactoryTest extends QuiltSpecification {
QuiltPathFactory.parse(PATH).toString() == STR

where:
_ | PATH | STR
_ | 'quilt+s3://reg#package=user/pkg' | 'reg#package=user%2fpkg'
_ | PATH | STR
_ | 'quilt+s3://reg#package=user/pkg' | 'reg#package=user%2fpkg'
_ | 'quilt+s3:/reg#package=user/pkg&path=test.md' | 'reg#package=user%2fpkg&path=test.md'
}

void 'should create Channel from URL'() {
Expand Down

0 comments on commit cb59d97

Please sign in to comment.