From b3cbb6a4836194687785ec78c853e42cafa80631 Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Wed, 8 Oct 2025 13:09:39 -0500 Subject: [PATCH] Track remote input path in FileHolder Signed-off-by: Ben Sherman --- .../nextflow/processor/TaskProcessor.groovy | 2 +- .../src/main/nextflow/file/FileHolder.groovy | 29 ++++++++++++------- .../src/main/nextflow/util/HashBuilder.java | 4 --- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy index 5f8e552a0e..9c4a0f75f4 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy @@ -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 { diff --git a/modules/nf-commons/src/main/nextflow/file/FileHolder.groovy b/modules/nf-commons/src/main/nextflow/file/FileHolder.groovy index 6d20e2c23c..37ffb3285c 100644 --- a/modules/nf-commons/src/main/nextflow/file/FileHolder.groovy +++ b/modules/nf-commons/src/main/nextflow/file/FileHolder.groovy @@ -20,11 +20,15 @@ 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 */ @@ -32,7 +36,7 @@ import groovy.util.logging.Slf4j @ToString(includePackage = false, includeNames = true) @EqualsAndHashCode @CompileStatic -class FileHolder { +class FileHolder implements CacheFunnel { final def sourceObj @@ -40,19 +44,15 @@ class FileHolder { 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()) } @@ -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 diff --git a/modules/nf-commons/src/main/nextflow/util/HashBuilder.java b/modules/nf-commons/src/main/nextflow/util/HashBuilder.java index c9ea56777e..3b90d1d48c 100644 --- a/modules/nf-commons/src/main/nextflow/util/HashBuilder.java +++ b/modules/nf-commons/src/main/nextflow/util/HashBuilder.java @@ -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; @@ -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);