diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy index 5a23825d44..6fe0bdd7a3 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy @@ -385,14 +385,16 @@ class PublishDir { processFileImpl(source, destination) } catch( FileAlreadyExistsException e ) { - if( checkIsSameRealPath(source, destination) ) - return + // don't copy source path if target is identical, but still emit the publish event + // see also https://github.com/nextflow-io/nf-prov/issues/22 + final sameRealPath = checkIsSameRealPath(source, destination) + // make sure destination and source does not overlap // see https://github.com/nextflow-io/nextflow/issues/2177 - if( checkSourcePathConflicts(destination)) + if( !sameRealPath && checkSourcePathConflicts(destination)) return - if( overwrite ) { + if( !sameRealPath && overwrite ) { FileHelper.deletePath(destination) processFileImpl(source, destination) }