Skip to content

Commit

Permalink
Fixed issue #65 An input file that is staged from a foreign file syst…
Browse files Browse the repository at this point in the history
…em lost it's original name
  • Loading branch information
pditommaso committed Aug 14, 2015
1 parent 4159a72 commit b8907b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/main/groovy/nextflow/processor/TaskProcessor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1146,9 +1146,10 @@ abstract class TaskProcessor {
* when it is a file stored in a "foreign" storage, copy
* to a local file and return a reference holder to the local file
*/
def result = Nextflow.tempFile(altName)

if( input instanceof Path ) {
log.debug "Copying to process workdir foreign file: ${input.toUri().toString()}"
def result = Nextflow.tempFile(input.getFileName().toString())
Files.copy(Files.newInputStream(input), result)
return new FileHolder(input, result)
}
Expand All @@ -1158,6 +1159,7 @@ abstract class TaskProcessor {
* to a local file
*/
def source = input?.toString() ?: ''
def result = Nextflow.tempFile(altName)
result.text = source
return new FileHolder(source, result)
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/groovy/nextflow/processor/TaskProcessorTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class TaskProcessorTest extends Specification {

/*
* when the input file is on the local file system
* simple return a refernce to it in the holder object
* simple return a reference to it in the holder object
*/
when:
holder = processor.normalizeInputToFile(localFile,null)
Expand All @@ -354,12 +354,12 @@ class TaskProcessorTest extends Specification {
when:
def remoteFile = TestHelper.createInMemTempFile('remote_file.txt')
remoteFile.text = 'alpha beta gamma delta'
holder = processor.normalizeInputToFile(remoteFile,'local_copy.txt')
holder = processor.normalizeInputToFile(remoteFile,'input.1')
then:
holder.sourceObj == remoteFile
holder.storePath.fileSystem == FileSystems.default
holder.storePath.text == 'alpha beta gamma delta'
holder.stageName == 'local_copy.txt'
holder.stageName == remoteFile.getName()

/*
* any generic input that is not a file is converted to a string
Expand Down

0 comments on commit b8907b5

Please sign in to comment.