Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,20 @@ void notResumableStartsOver() throws Exception {

Path source = randomFile("fresh", 50 * 1024);
Path target = dir.resolve("fresh.out");
CompletableFuture<IncomingTransfer> incoming = acceptInto(receiver, target);
CompletableFuture<IncomingTransfer> incoming = new CompletableFuture<>();
receiver.onOffer(offer -> {
// A partial file of the same transfer, from before, is not continued.
// Written before the accept, which opens it.
try {
Files.write(dir.resolve("fresh.out." + offer.id().substring(0, 16) + ".part"), new byte[10 * 1024]);
incoming.complete(offer.accept(target));
}
catch (IOException e) {
incoming.completeExceptionally(e);
}
});
OutgoingTransfer outgoing = sender.send(source);

// A partial file of the same transfer, from before, is not continued.
Files.write(dir.resolve("fresh.out." + outgoing.id().substring(0, 16) + ".part"), new byte[10 * 1024]);

await(outgoing.whenDone());
await(await(incoming).whenDone());
assertArrayEquals(Files.readAllBytes(source), Files.readAllBytes(target));
Expand Down
Loading