Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage files to tmp files, then atomically move #1713

Merged
merged 2 commits into from
Aug 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion modules/nextflow/src/main/groovy/nextflow/file/FilePorter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package nextflow.file

import java.nio.file.Files
import java.nio.file.NoSuchFileException
import java.nio.file.Path
import java.util.concurrent.ExecutionException
Expand Down Expand Up @@ -284,8 +285,16 @@ class FilePorter {
log.debug "Local cache found for foreign file ${source.toUriString()} at ${target.toUriString()}"
return target
}

log.debug "Copying foreign file ${source.toUriString()} to work dir: ${target.toUriString()}"
return FileHelper.copyPath(source, target)

// copy to a temp file first and move to ensure that a partial copy doesn't get cached as completed.
// use the target parent dir as the temp dir because it'lll have the same permissions.
def tmpFile = target.getParent().resolve( "temp-${UUID.randomUUID()}" )
log.debug "Using temp file ${tmpFile.toUriString()} for ${target.toUriString()}"

FileHelper.copyPath(source, tmpFile)
return FileHelper.movePath(tmpFile, target)
}

synchronized String getMessageAndClear() {
Expand Down