From 7c28553f5be04a7db175af2612df65afe54d29ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 10 Jul 2015 13:41:47 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20check=20identifiers=20twice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit They are already checked in the super class, FcpReplySequence. --- .../fcp/quelaton/ClientPutCommandImpl.java | 42 ++++++++-------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java index 6e5f7e1..8a2ebfe 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java @@ -119,7 +119,6 @@ class ClientPutCommandImpl implements ClientPutCommand { private class ClientPutReplySequence extends FcpReplySequence> { private final AtomicReference originalClientPut = new AtomicReference<>(); - private final AtomicReference identifier = new AtomicReference<>(); private final AtomicReference directory = new AtomicReference<>(); private final AtomicReference finalKey = new AtomicReference<>(); private final AtomicBoolean putFinished = new AtomicBoolean(); @@ -141,7 +140,6 @@ class ClientPutCommandImpl implements ClientPutCommand { @Override public ListenableFuture> send(FcpMessage fcpMessage) throws IOException { originalClientPut.set(fcpMessage); - identifier.set(fcpMessage.getField("Identifier")); String filename = fcpMessage.getField("Filename"); if (filename != null) { directory.set(new File(filename).getParent()); @@ -151,49 +149,39 @@ class ClientPutCommandImpl implements ClientPutCommand { @Override protected void consumePutSuccessful(PutSuccessful putSuccessful) { - if (putSuccessful.getIdentifier().equals(identifier.get())) { - finalKey.set(new Key(putSuccessful.getURI())); - putFinished.set(true); - } + finalKey.set(new Key(putSuccessful.getURI())); + putFinished.set(true); } @Override protected void consumePutFailed(PutFailed putFailed) { - if (putFailed.getIdentifier().equals(identifier.get())) { - putFinished.set(true); - } + putFinished.set(true); } @Override protected void consumeProtocolError(ProtocolError protocolError) { - if (protocolError.getIdentifier().equals(identifier.get())) { - if (protocolError.getCode() == 25) { - setIdentifier(directory.get()); - sendMessage(new TestDDARequest(directory.get(), true, false)); - } else { - putFinished.set(true); - } + if (protocolError.getCode() == 25) { + setIdentifier(directory.get()); + sendMessage(new TestDDARequest(directory.get(), true, false)); + } else { + putFinished.set(true); } } @Override protected void consumeTestDDAReply(TestDDAReply testDDAReply) { - if (testDDAReply.getDirectory().equals(directory.get())) { - try { - String readContent = Files.readAllLines(new File(testDDAReply.getReadFilename()).toPath()).get(0); - sendMessage(new TestDDAResponse(directory.get(), readContent)); - } catch (IOException e) { - sendMessage(new TestDDAResponse(directory.get(), "failed-to-read")); - } + try { + String readContent = Files.readAllLines(new File(testDDAReply.getReadFilename()).toPath()).get(0); + sendMessage(new TestDDAResponse(directory.get(), readContent)); + } catch (IOException e) { + sendMessage(new TestDDAResponse(directory.get(), "failed-to-read")); } } @Override protected void consumeTestDDAComplete(TestDDAComplete testDDAComplete) { - if (testDDAComplete.getDirectory().equals(directory.get())) { - setIdentifier(originalClientPut.get().getField("Identifier")); - sendMessage(originalClientPut.get()); - } + setIdentifier(originalClientPut.get().getField("Identifier")); + sendMessage(originalClientPut.get()); } @Override -- 2.7.4