Skip to content

Commit

Permalink
test isLocalProvider
Browse files Browse the repository at this point in the history
contains vs startsWith
  • Loading branch information
drernie committed Sep 11, 2023
1 parent 53d86c9 commit fedc65f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,23 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
return path.getFileSystem().provider()
}

static boolean localProvider(Path path) {
static boolean isLocalProvider(Path path) {
FileSystemProvider provider = provider(path)
String providerName = provider?.class?.name?.toLowerCase() ?: '-'
println("QuiltFileSystemProvider.localProvider[${path}] -> ${providerName}")
return providerName.startsWith("unix") || providerName.startsWith("win") ||\
providerName.startsWith("mac") || providerName.startsWith("fat")
String providerName = provider?.class?.name?.toLowerCase() ?: 'N/A'
println("QuiltFileSystemProvider.isLocalProvider[${path}] -> ${providerName}")
return providerName.contains("unix") || providerName.contains("win") ||\
providerName.contains("mac") || providerName.contains("fat") ||\
providerName == 'N/A'
}

boolean canDownload(Path source, Path target) {
log.debug("QuiltFileSystemProvider.canDownload[${source}] -> ${target}")
return localProvider(target) && source instanceof QuiltPath
return isLocalProvider(target) && source instanceof QuiltPath
}

boolean canUpload(Path source, Path target) {
log.debug("QuiltFileSystemProvider.canUpload[${source}] -> ${target}")
return localProvider(source) && target instanceof QuiltPath
return isLocalProvider(source) && target instanceof QuiltPath
}

void download(Path source, Path target, CopyOption... options) throws IOException {
Expand Down Expand Up @@ -397,7 +398,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr

@Override
boolean isHidden(Path path) throws IOException {
return path.getFileName()?.toString()?.startsWith('.')
return path.getFileName()?.toString()?.contains('.')
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package nextflow.quilt.nio

import nextflow.quilt.QuiltSpecification
import groovy.transform.CompileDynamic
import java.nio.file.Path
import java.nio.file.Paths

/**
*
Expand All @@ -22,4 +24,14 @@ class QuiltFileSystemProviderTest extends QuiltSpecification {
// newDirectoryStream returns package path for write
// do we need a new schema for quilt+local?

void 'should recognize isLocalProvider'() {
given:
Path local = Paths.get('file:///tmp')
Path remote = Paths.get(new URI(fullURL))

expect:
QuiltFileSystemProvider.isLocalProvider(local) == true
QuiltFileSystemProvider.isLocalProvider(remote) == false
}

}

0 comments on commit fedc65f

Please sign in to comment.