From b6c8387dfd1ab617bbdca75aed356b2207f6fab8 Mon Sep 17 00:00:00 2001 From: "Dr. Ernie Prabhakar" Date: Fri, 26 Jan 2024 16:46:16 -0800 Subject: [PATCH] return path string for getFileName --- .../src/main/nextflow/quilt/nio/QuiltPath.groovy | 16 +++++++++++++--- .../test/nextflow/quilt/nio/QuiltPathTest.groovy | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy index 353f88a9..3dba412f 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy @@ -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") } @@ -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 @@ -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() } diff --git a/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltPathTest.groovy b/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltPathTest.groovy index 727053b0..0f06fc4e 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltPathTest.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/nio/QuiltPathTest.groovy @@ -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'