Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ class TaskProcessor {
if( item instanceof Path || coerceToPath ) {
final path = resolvePath(item)
final target = executor.isForeignFile(path) ? foreignFiles.addToForeign(path) : path
final holder = new FileHolder(target)
final holder = new FileHolder(path, target)
files << holder
}
else {
Expand Down
29 changes: 19 additions & 10 deletions modules/nf-commons/src/main/nextflow/file/FileHolder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@ package nextflow.file
import java.nio.file.FileSystems
import java.nio.file.Path

import com.google.common.hash.Hasher
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.PackageScope
import groovy.transform.ToString
import groovy.util.logging.Slf4j
import nextflow.util.CacheFunnel
import nextflow.util.CacheHelper
import nextflow.util.CacheHelper.HashMode
/**
* Implements a special {@code Path} used to stage files in the work area
*/
@Slf4j
@ToString(includePackage = false, includeNames = true)
@EqualsAndHashCode
@CompileStatic
class FileHolder {
class FileHolder implements CacheFunnel {

final def sourceObj

final Path storePath

final String stageName

FileHolder( Path inputFile ) {
assert inputFile
this.sourceObj = inputFile
this.storePath = real(inputFile)
this.stageName = norm(inputFile.getFileName())
FileHolder( Path path ) {
this.sourceObj = path
this.storePath = real(path)
this.stageName = norm(path.getFileName())
}

FileHolder( def origin, Path path ) {
assert origin != null
assert path != null

this.sourceObj = origin
this.storePath = path
this.storePath = real(path)
this.stageName = norm(path.getFileName())
}

Expand All @@ -66,10 +66,19 @@ class FileHolder {
new FileHolder( this.sourceObj, this.storePath, stageName )
}

Path getSourcePath() {
sourceObj instanceof Path ? sourceObj : null
}

Path getStorePath() { storePath }

String getStageName() { stageName }

@Override
Hasher funnel(Hasher hasher, HashMode mode) {
return CacheHelper.hasher(hasher, sourceObj, mode)
}

@PackageScope
static FileHolder get( def path, def name = null ) {
Path storePath = path as Path
Expand Down
4 changes: 0 additions & 4 deletions modules/nf-commons/src/main/nextflow/util/HashBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import nextflow.ISession;
import nextflow.extension.Bolts;
import nextflow.extension.FilesEx;
import nextflow.file.FileHolder;
import nextflow.io.SerializableMarker;
import nextflow.script.types.Bag;
import org.slf4j.Logger;
Expand Down Expand Up @@ -163,9 +162,6 @@ else if( value instanceof Collection)
for( Object item : ((Collection)value) )
with(item);

else if( value instanceof FileHolder )
with(((FileHolder) value).getSourceObj());

else if( value instanceof Path )
hashFile(hasher, (Path)value, mode, basePath);

Expand Down