diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy index 637f059b..d5aa194d 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy @@ -46,6 +46,8 @@ import nextflow.Session import nextflow.file.FileSystemTransferAware import nextflow.quilt.jep.QuiltParser import nextflow.quilt.jep.QuiltPackage +import sun.nio.fs.UnixFileSystemProvider +import sun.nio.fs.MacOSXFileSystemProvider /** * Implements NIO File system provider for Quilt Blob Storage @@ -85,22 +87,33 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr return path.getFileSystem().provider() } - boolean canUpload(Path source, Path target) { - log.debug("QuiltFileSystemProvider.canUpload[${source}] -> ${target}") - return false + static boolean localProvider(Path path) { + FileSystemProvider provider = provider(path) + log.debug("QuiltFileSystemProvider.localProvider[${path}] -> ${provider}") + return provider instanceof UnixFileSystemProvider || + provider instanceof MacOSXFileSystemProvider } boolean canDownload(Path source, Path target) { log.debug("QuiltFileSystemProvider.canDownload[${source}] -> ${target}") - return false + return localProvider(target) && source instanceof QuiltPath + } + + boolean canUpload(Path source, Path target) { + log.debug("QuiltFileSystemProvider.canUpload[${source}] -> ${target}") + return localProvider(source) && target instanceof QuiltPath } void download(Path source, Path target, CopyOption... options) throws IOException { - throw new UnsupportedOperationException("Operation 'download' is not supported by QuiltFileSystem") + QuiltPath qSource = asQuiltPath(source) + Path local_source = qSource.localPath() + Files.copy(local_source, target, options) } void upload(Path source, Path target, CopyOption... options) throws IOException { - throw new UnsupportedOperationException("Operation 'upload' is not supported by QuiltFileSystem") + QuiltPath qTarget = asQuiltPath(target) + Path local_target = qTarget.localPath() + Files.copy(source, local_target, options) } /** @@ -359,7 +372,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr @Override void copy(Path from, Path to, CopyOption... options) throws IOException { - //log.debug("Attempting `copy`: ${from} -> ${to}") + log.debug("Attempting `copy`: ${from} -> ${to}") assert provider(from) == provider(to) if (from == to) { return // nothing to do -- just return diff --git a/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy b/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy index 443ae4b7..87a273f8 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy @@ -86,6 +86,31 @@ class QuiltPackageTest extends QuiltSpecification { Files.exists(installPath) } + void 'should copy temp files into install folder'() { + given: + String filename = 'test.txt' + Path installPath = pkg.packageDest() + Path tempFile = File.createTempFile('test', '.txt').toPath() + println("tempFile: "+tempFile); + Path installedFile = Paths.get(installPath.toString(), filename) + expect: + Files.exists(tempFile) + Files.exists(installPath) + !Files.exists(installedFile) + Files.copy(tempFile, installedFile) + Files.exists(installedFile) + } + + void 'should copy package files to temp Path'() { + given: + Path installPath = pkg.packageDest() + expect: + Files.exists(installPath) + Files.isDirectory(installPath) + Files.readAttributes(installPath, BasicFileAttributes) + } + + void 'should get attributes for package folder'() { given: def root = qpath.getRoot() @@ -106,6 +131,7 @@ class QuiltPackageTest extends QuiltSpecification { Files.readAttributes(qpath, BasicFileAttributes) } + void 'should return null on failed install'() { given: def url2 = TEST_URL.replace('quilt-', 'quilted-') @@ -125,11 +151,6 @@ class QuiltPackageTest extends QuiltSpecification { qpath.deinstall() then: !Files.exists(qpath.localPath(false)) - - /*when: - Files.readAttributes(qpath, BasicFileAttributes) - then: - thrown(java.nio.file.NoSuchFileException)*/ } void 'should iterate over installed files '() {