Skip to content

Commit

Permalink
Don't publish external files (#5480)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Dec 10, 2024
1 parent 1d6c28f commit bec0e93
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,19 @@ class PublishOp {

/**
* Extract files from a received value for publishing.
* Files external to the work directory are not published.
*
* @param result
* @param value
*/
protected Map<Path,Set<Path>> collectFiles(Map<Path,Set<Path>> result, value) {
if( value instanceof Path ) {
final sourceDir = getTaskDir(value)
if( sourceDir !in result )
result[sourceDir] = new HashSet(10)
result[sourceDir] << value
if( sourceDir != null ) {
if( sourceDir !in result )
result[sourceDir] = new HashSet(10)
result[sourceDir] << value
}
}
else if( value instanceof Collection ) {
for( final el : value )
Expand Down Expand Up @@ -230,12 +233,14 @@ class PublishOp {
throw new IllegalArgumentException("Index file record must be a list, map, or file: ${value} [${value.class.simpleName}]")
}

private Path normalizePath(Path path, targetDirOrClosure) {
private String normalizePath(Path path, targetDirOrClosure) {
if( targetDirOrClosure instanceof Closure )
return (targetDirOrClosure.call(path.getName()) as Path).normalize()
return (targetDirOrClosure.call(path.getName()) as Path).normalize().toUriString()
final sourceDir = getTaskDir(path)
if( sourceDir == null )
return path.toUriString()
final targetDir = targetDirOrClosure as Path
return targetDir.resolve(sourceDir.relativize(path)).normalize()
return targetDir.resolve(sourceDir.relativize(path)).normalize().toUriString()
}

/**
Expand Down

0 comments on commit bec0e93

Please sign in to comment.