X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FClientPutCommandImpl.java;h=44850af511b68a9efbab2e300fbd77f304051898;hb=65b7fe5c454d82b49211526e5688f596e8e70d5a;hp=f0a670616f244fa3c82a41129b2f3a305d4dd29a;hpb=12eb8641be8a71957856ec76c9522d80394e5cd6;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java index f0a6706..44850af 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java @@ -54,31 +54,31 @@ class ClientPutCommandImpl implements ClientPutCommand { } @Override - public Keyed> redirectTo(Key key) { - this.redirectUri.set(Objects.requireNonNull(key, "key must not be null").getKey()); + public WithUri> redirectTo(String uri) { + this.redirectUri.set(Objects.requireNonNull(uri, "uri must not be null")); return this::key; } @Override - public Keyed> from(File file) { + public WithUri> from(File file) { this.file.set(Objects.requireNonNull(file, "file must not be null")); return this::key; } @Override - public Lengthed>> from(InputStream inputStream) { + public WithLength>> from(InputStream inputStream) { payload.set(Objects.requireNonNull(inputStream, "inputStream must not be null")); return this::length; } - private Keyed> length(long length) { + private WithUri> length(long length) { this.length.set(length); return this::key; } - private ListenableFuture> key(Key key) { + private ListenableFuture> key(String uri) { String identifier = new RandomIdentifierGenerator().generate(); - ClientPut clientPut = createClientPutCommand(key.getKey(), identifier); + ClientPut clientPut = createClientPutCommand(uri, identifier); return threadPool.submit(() -> new ClientPutReplySequence().send(clientPut).get()); } @@ -166,8 +166,12 @@ class ClientPutCommandImpl implements ClientPutCommand { @Override protected void consumeProtocolError(ProtocolError protocolError) { - if (protocolError.getIdentifier().equals(identifier.get()) && (protocolError.getCode() == 25)) { - sendMessage(new TestDDARequest(directory.get(), true, false)); + if (protocolError.getIdentifier().equals(identifier.get())) { + if (protocolError.getCode() == 25) { + sendMessage(new TestDDARequest(directory.get(), true, false)); + } else { + putFinished.set(true); + } } } @@ -178,7 +182,6 @@ class ClientPutCommandImpl implements ClientPutCommand { String readContent = Files.readAllLines(new File(testDDAReply.getReadFilename()).toPath()).get(0); sendMessage(new TestDDAResponse(directory.get(), readContent)); } catch (IOException e) { - e.printStackTrace(); sendMessage(new TestDDAResponse(directory.get(), "failed-to-read")); } }