Skip to content

Commit ab13b83

Browse files
committed
Alternative solution
Signed-off-by: Robrecht Cannoodt <[email protected]>
1 parent b3d4fe0 commit ab13b83

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed

modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy

+9-3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import nextflow.file.FileHelper
8080
import nextflow.file.FileHolder
8181
import nextflow.file.FilePatternSplitter
8282
import nextflow.file.FilePorter
83+
import nextflow.file.RemoteFileHolder
8384
import nextflow.plugin.Plugins
8485
import nextflow.processor.tip.TaskTipProvider
8586
import nextflow.script.BaseScript
@@ -1939,9 +1940,14 @@ class TaskProcessor {
19391940

19401941
if( item instanceof Path || coerceToPath ) {
19411942
def path = normalizeToPath(item)
1942-
def target = executor.isForeignFile(path) ? batch.addToForeign(path) : path
1943-
def holder = new FileHolder(target, path)
1944-
files << holder
1943+
if (executor.isForeignFile(path)) {
1944+
def target = batch.addToForeign(path)
1945+
def holder = new RemoteFileHolder(target, path)
1946+
files << holder
1947+
} else {
1948+
def holder = new FileHolder(path)
1949+
files << holder
1950+
}
19451951
}
19461952
else {
19471953
files << normalizeInputToFile(item, "input.${++count}")

modules/nf-commons/src/main/nextflow/file/FileHolder.groovy

+3-10
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,26 @@ class FileHolder {
4040

4141
final String stageName
4242

43-
final Path origPath
44-
45-
FileHolder( Path inputFile, Path origPath = null ) {
43+
FileHolder( Path inputFile ) {
4644
assert inputFile
4745
this.sourceObj = inputFile
4846
this.storePath = real(inputFile)
4947
this.stageName = norm(inputFile.getFileName())
50-
this.origPath = origPath
5148
}
5249

53-
FileHolder( def origin, Path path, Path origPath = null ) {
50+
FileHolder( def origin, Path path ) {
5451
assert origin != null
5552
assert path != null
5653

5754
this.sourceObj = origin
5855
this.storePath = path
5956
this.stageName = norm(path.getFileName())
60-
this.origPath = origPath
6157
}
6258

63-
protected FileHolder( def source, Path store, def stageName, Path origPath = null ) {
59+
protected FileHolder( def source, Path store, def stageName ) {
6460
this.sourceObj = source
6561
this.storePath = store
6662
this.stageName = norm(stageName)
67-
this.origPath = origPath
6863
}
6964

7065
FileHolder withName( def stageName ) {
@@ -75,8 +70,6 @@ class FileHolder {
7570

7671
String getStageName() { stageName }
7772

78-
Path getOrigPath() { origPath }
79-
8073
@PackageScope
8174
static FileHolder get( def path, def name = null ) {
8275
Path storePath = path as Path
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2013-2024, Seqera Labs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package nextflow.file
18+
19+
import java.nio.file.Path
20+
21+
import groovy.transform.CompileStatic
22+
import groovy.transform.EqualsAndHashCode
23+
import groovy.transform.ToString
24+
import groovy.util.logging.Slf4j
25+
26+
import nextflow.file.FileHolder
27+
28+
/**
29+
* Implements a special {@code Path} used to stage files in the work area
30+
*/
31+
@Slf4j
32+
@ToString(includePackage = false, includeNames = true)
33+
@EqualsAndHashCode
34+
@CompileStatic
35+
class RemoteFileHolder extends FileHolder {
36+
37+
final Path origPath
38+
39+
RemoteFileHolder( Path inputFile, Path origPath ) {
40+
super(inputFile)
41+
this.origPath = origPath
42+
}
43+
44+
RemoteFileHolder( def origin, Path path, Path origPath ) {
45+
super(origin, path)
46+
this.origPath = origPath
47+
}
48+
49+
protected RemoteFileHolder( def source, Path store, def stageName, Path origPath ) {
50+
super(origin, store, stageName)
51+
this.origPath = origPath
52+
}
53+
54+
Path getOrigPath() { origPath }
55+
}

0 commit comments

Comments
 (0)