Skip to content

Commit

Permalink
Add support for locks in write feature for #5687.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex0x08 authored and dkocher committed Nov 30, 2018
1 parent 06c2ba2 commit a7dedeb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
29 changes: 20 additions & 9 deletions core/src/main/java/ch/cyberduck/core/transfer/TransferStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public class TransferStatus implements StreamCancelation, StreamProgress {
* Change target filename
*/
private Rename rename
= new Rename();
= new Rename();

/**
* Temporary filename only used for transfer. Rename when file transfer is complete
*/
private final Displayname displayname
= new Displayname();
= new Displayname();

/**
* Target file or directory already exists
Expand Down Expand Up @@ -84,7 +84,7 @@ public class TransferStatus implements StreamCancelation, StreamProgress {
* The number of transferred bytes. Must be less or equals size.
*/
private final AtomicLong offset
= new AtomicLong(0);
= new AtomicLong(0);
/**
* Transfer size. May be less than the file size in attributes or 0 if creating symbolic links.
*/
Expand All @@ -94,13 +94,13 @@ public class TransferStatus implements StreamCancelation, StreamProgress {
* The transfer has been canceled by the user.
*/
private final AtomicBoolean canceled
= new AtomicBoolean();
= new AtomicBoolean();

private final AtomicBoolean complete
= new AtomicBoolean();
= new AtomicBoolean();

private final CountDownLatch done
= new CountDownLatch(1);
= new CountDownLatch(1);

private Checksum checksum = Checksum.NONE;

Expand Down Expand Up @@ -137,13 +137,13 @@ public class TransferStatus implements StreamCancelation, StreamProgress {
private Long timestamp;

private Map<String, String> parameters
= Collections.emptyMap();
= Collections.emptyMap();

private Map<String, String> metadata
= Collections.emptyMap();
= Collections.emptyMap();

private List<TransferStatus> segments
= Collections.emptyList();
= Collections.emptyList();

/**
* Part number
Expand All @@ -170,6 +170,8 @@ public class TransferStatus implements StreamCancelation, StreamProgress {
*/
private int retry;

private Object lockId;

public TransferStatus() {
// Default
}
Expand Down Expand Up @@ -203,6 +205,7 @@ public TransferStatus(final TransferStatus copy) {
this.filekey = copy.filekey;
this.nonces = copy.nonces;
this.retry = copy.retry;
this.lockId = copy.lockId;
}

/**
Expand Down Expand Up @@ -584,6 +587,14 @@ public boolean isRetry() {
return retry > 0;
}

public Object getLockId() {
return lockId;
}

public void setLockId(final Object lockId) {
this.lockId = lockId;
}

@Override
public boolean equals(final Object o) {
if(this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public HttpResponseOutputStream<String> write(final Path file, final TransferSta
headers.add(new BasicHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE));
}
}
if(status.getLockId() != null) {
headers.add(new BasicHeader("If", "(<" + status.getLockId() + ">)"));
}
return this.write(file, headers, status);
}

Expand Down

0 comments on commit a7dedeb

Please sign in to comment.