Skip to content

Commit

Permalink
Use fusion symlinks file to resolve links
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Sep 29, 2023
1 parent 815709c commit 945c01f
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import java.util.concurrent.ExecutorService
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.Memoized
import groovy.transform.PackageScope
import groovy.transform.ToString
import groovy.util.logging.Slf4j
Expand Down Expand Up @@ -287,12 +288,40 @@ class PublishDir {
// resolve Fusion symlinks
if( FusionHelper.isFusionEnabled(Global.session as Session) ) {
final inputFiles = task.getInputFilesMap()
files = files.collect { inputFiles.getOrDefault(it.name, it) } as Set<Path>
files = files.collect { file ->
file.name in inputFiles
? resolveFusionLink(inputFiles[file.name])
: file
} as Set<Path>
}

apply0(files)
}

/**
* Resolve a Fusion symlink by following the .fusion.symlinks
* file in the task directory until the original file is reached.
*
* @param file
*/
@CompileStatic
protected Path resolveFusionLink(Path file) {
while( file.name in getFusionLinks(file.parent) )
file = file.text.replace('/fusion/s3/', 's3://') as Path
return file
}

@CompileStatic
@Memoized
protected List<String> getFusionLinks(Path workDir) {
try {
final file = workDir.resolve('.fusion.symlinks')
return file.text.tokenize('\n')
}
catch( NoSuchFileException ) {
return []
}
}

@CompileStatic
protected void apply1(Path source, boolean inProcess ) {
Expand Down

0 comments on commit 945c01f

Please sign in to comment.