Skip to content

Commit c2fc498

Browse files
authored
Merge pull request #65 from latchbio/rahuldesai1/remove-delete-on-overwrite
remove delete on write for latch files
2 parents d83ab51 + 421b91d commit c2fc498

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Latch Nextflow Changelog
22

3+
## 2.4.1
4+
5+
## Fixed
6+
* Remove deletion of latch files when overwriting
7+
38
## 2.4.0
49

510
## Updated

LATCH_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.3.6
1+
v2.4.1

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
package nextflow.processor
1818

19+
import nextflow.file.CopyOptions
20+
21+
import java.nio.file.StandardCopyOption
22+
import java.nio.file.StandardOpenOption
23+
1924
import static nextflow.util.CacheHelper.*
2025

2126
import java.nio.file.FileAlreadyExistsException
@@ -425,10 +430,16 @@ class PublishDir {
425430

426431
if( !sameRealPath && shouldOverwrite(source, destination) ) {
427432
log.warn "Overwriting file at ${destination.toUriString()}"
428-
FileHelper.deletePath(destination)
429-
processFileImpl(source, destination)
433+
434+
if (destination.getFileSystem().provider().getScheme().equals("latch")) {
435+
processFileImpl(source, destination, true)
436+
} else {
437+
FileHelper.deletePath(destination)
438+
processFileImpl(source, destination)
439+
}
440+
430441
} else {
431-
log.debug "Skipping file. File already exists at ${destination.toUriString()}"
442+
log.debug "Skipping upload. File already exists at ${destination.toUriString()}"
432443
}
433444
}
434445

@@ -498,7 +509,7 @@ class PublishDir {
498509
return sourceHash != targetHash
499510
}
500511

501-
protected void processFileImpl( Path source, Path destination ) {
512+
protected void processFileImpl( Path source, Path destination, boolean overwrite = false ) {
502513
log.trace "publishing file: $source -[$mode]-> $destination"
503514

504515
if( !mode || mode == Mode.SYMLINK ) {
@@ -512,10 +523,18 @@ class PublishDir {
512523
FilesEx.mklink(source, [hard:true], destination)
513524
}
514525
else if( mode == Mode.MOVE ) {
515-
FileHelper.movePath(source, destination)
526+
if (overwrite) {
527+
FileHelper.movePath(source, destination, StandardCopyOption.REPLACE_EXISTING)
528+
} else {
529+
FileHelper.movePath(source, destination)
530+
}
516531
}
517532
else if( mode == Mode.COPY ) {
518-
FileHelper.copyPath(source, destination)
533+
if (overwrite) {
534+
FileHelper.copyPath(source, destination, StandardCopyOption.REPLACE_EXISTING)
535+
} else {
536+
FileHelper.copyPath(source, destination)
537+
}
519538
}
520539
else if( mode == Mode.COPY_NO_FOLLOW ) {
521540
FileHelper.copyPath(source, destination, LinkOption.NOFOLLOW_LINKS)

modules/nf-commons/src/main/nextflow/file/CopyMoveHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ static void copyToForeignTarget(Path source, Path target, CopyOption... options)
174174

175175
// delete target if it exists and REPLACE_EXISTING is specified
176176
if (opts.replaceExisting()) {
177-
FileHelper.deletePath(target);
177+
// rahul: latch paths can be overridden and do not require explicit delete
178+
if (!target.getFileSystem().provider().getScheme().equals("latch")) {
179+
FileHelper.deletePath(target);
180+
}
178181
} else if (Files.exists(target)) {
179182
throw new FileAlreadyExistsException(target.toString());
180183
}

0 commit comments

Comments
 (0)