From ca2d86cf87ca3eaab5631c2ad3f18cec66a7d86b Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sat, 15 Nov 2014 14:52:51 +0100 Subject: better cleanup after unsuccesful transfers --- .../conversations/xmpp/jingle/JingleConnection.java | 6 ++++++ .../conversations/xmpp/jingle/JingleInbandTransport.java | 16 +++++++++++++++- .../conversations/xmpp/jingle/JingleSocks5Transport.java | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index d6bcf55b..e4e00e43 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -726,6 +726,9 @@ public class JingleConnection implements Downloadable { this.mJingleConnectionManager.finishConnection(this); if (this.responder.equals(account.getJid())) { this.message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_FAILED)); + if (this.file!=null) { + file.delete(); + } this.mXmppConnectionService.updateConversationUi(); } else { this.mXmppConnectionService.markMessage(this.message, @@ -743,6 +746,9 @@ public class JingleConnection implements Downloadable { if (this.message != null) { if (this.responder.equals(account.getJid())) { this.message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_FAILED)); + if (this.file!=null) { + file.delete(); + } this.mXmppConnectionService.updateConversationUi(); } else { this.mXmppConnectionService.markMessage(this.message, diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java index 982fa964..04b225d0 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java @@ -34,7 +34,7 @@ public class JingleInbandTransport extends JingleTransport { private JingleConnection connection; private InputStream fileInputStream = null; - private OutputStream fileOutputStream; + private OutputStream fileOutputStream = null; private long remainingSize = 0; private long fileSize = 0; private MessageDigest digest; @@ -129,6 +129,20 @@ public class JingleInbandTransport extends JingleTransport { @Override public void disconnect() { this.connected = false; + if (this.fileOutputStream != null) { + try { + this.fileOutputStream.close(); + } catch (IOException e) { + + } + } + if (this.fileInputStream != null) { + try { + this.fileInputStream.close(); + } catch (IOException e) { + + } + } } private void sendNextBlock() { diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java index 1ed3fa11..c3419580 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java @@ -197,6 +197,20 @@ public class JingleSocks5Transport extends JingleTransport { } public void disconnect() { + if (this.outputStream != null) { + try { + this.outputStream.close(); + } catch (IOException e) { + + } + } + if (this.inputStream != null) { + try { + this.inputStream.close(); + } catch (IOException e) { + + } + } if (this.socket != null) { try { this.socket.close(); -- cgit v1.2.3