Skip to content

Commit

Permalink
return path string for getFileName
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Jan 27, 2024
1 parent 0e4726f commit b6c8387
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ final class QuiltPath implements Path, Comparable {
private final QuiltFileSystem filesystem
private final QuiltParser parsed
private final String[] paths
private final boolean isFileName

QuiltPath(QuiltFileSystem filesystem, QuiltParser parsed) {
QuiltPath(QuiltFileSystem filesystem, QuiltParser parsed, boolean isFileName = false) {
this.filesystem = filesystem
this.parsed = parsed
this.paths = parsed.getPaths()
this.isFileName = isFileName
log.debug("Creating QuiltPath: $parsed")
}

Expand Down Expand Up @@ -110,8 +112,10 @@ final class QuiltPath implements Path, Comparable {

@Override
Path getFileName() {
//log.debug("getFileName`[${this}]: paths=$paths")
return isJustPackage() ? this : new QuiltPath(filesystem, parsed.lastPath()) // IF DIRECTORY
log.debug("getFileName[${this}]: paths=$paths")
// if (isJustPackage()) { return this } // IF DIRECTORY
QuiltPath filePath = new QuiltPath(filesystem, parsed.lastPath(), true)
return filePath
}

@Override
Expand Down Expand Up @@ -215,6 +219,12 @@ final class QuiltPath implements Path, Comparable {

@Override
String toString() {
println("toString.parsed[isFileName=$isFileName]: $parsed")
String filename = paths.size() > 0 ? paths[-1] : ''
println("toString:filename: ${filename}")
if (isFileName) {
return filename
}
return parsed.toString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ class QuiltPathTest extends QuiltSpecification {
'#path=file-name.txt' | false | 'bucket.so.me'
}

@Ignore
void 'should validate getFileName'() {
expect:
pathify(path).getFileName() == pathify(fileName)
pathify(path).getFileName().toString() == fileName

where:
path | fileName
'bucket' | ''
'bucket#path=file.txt' | 'file.txt'
'bucket#path=some%2fdata%2ffile.txt' | 'file.txt'
'#path=file-name.txt' | 'file-name.txt'
Expand Down

0 comments on commit b6c8387

Please sign in to comment.