diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-04-25 14:08:24 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-04-25 14:08:24 +0200 |
commit | d07baccf9722a464111273f7a364139ce534fad4 (patch) | |
tree | 66db01e0f8d50de15c0df3615a436f1882d8953c /src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java | |
parent | 5e1492fbff8c8377abedac776405a09424a6a20e (diff) |
cleaned up file handling
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java | 17 |
1 files changed, 7 insertions, 10 deletions
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 c34195804..72015a058 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java @@ -11,6 +11,7 @@ import java.security.NoSuchAlgorithmException; import java.util.Arrays; import eu.siacs.conversations.entities.DownloadableFile; +import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.utils.CryptoHelper; public class JingleSocks5Transport extends JingleTransport { @@ -126,25 +127,19 @@ public class JingleSocks5Transport extends JingleTransport { } catch (NoSuchAlgorithmException e) { callback.onFileTransferAborted(); } finally { - try { - if (fileInputStream != null) { - fileInputStream.close(); - } - } catch (IOException e) { - callback.onFileTransferAborted(); - } + FileBackend.close(fileInputStream); } } }).start(); } - public void receive(final DownloadableFile file, - final OnFileTransmissionStatusChanged callback) { + public void receive(final DownloadableFile file, final OnFileTransmissionStatusChanged callback) { new Thread(new Runnable() { @Override public void run() { + OutputStream fileOutputStream = null; try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.reset(); @@ -152,7 +147,7 @@ public class JingleSocks5Transport extends JingleTransport { socket.setSoTimeout(30000); file.getParentFile().mkdirs(); file.createNewFile(); - OutputStream fileOutputStream = file.createOutputStream(); + fileOutputStream = file.createOutputStream(); if (fileOutputStream == null) { callback.onFileTransferAborted(); return; @@ -183,6 +178,8 @@ public class JingleSocks5Transport extends JingleTransport { callback.onFileTransferAborted(); } catch (NoSuchAlgorithmException e) { callback.onFileTransferAborted(); + } finally { + FileBackend.close(fileOutputStream); } } }).start(); |