aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-06-03 03:05:20 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-06-03 03:05:20 +0200
commit3eab3291dee7a3d20d2cf6ccb14da3e59562470f (patch)
tree87975cab962ff5eddb64f96a4cc0772d36e55188
parenta4fb6bb3a3fd06435cbb3244f120506e47792e1b (diff)
properly calculate remaining size. should fix #1243
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java9
1 files changed, 7 insertions, 2 deletions
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 29efcf8f..8da53c1b 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
@@ -160,13 +160,18 @@ public class JingleInbandTransport extends JingleTransport {
byte[] buffer = new byte[this.bufferSize];
try {
int count = fileInputStream.read(buffer);
- this.remainingSize -= count;
- if (count != buffer.length && count != -1) {
+ if (count == -1) {
+ file.setSha1Sum(CryptoHelper.bytesToHex(digest.digest()));
+ this.onFileTransmissionStatusChanged.onFileTransmitted(file);
+ fileInputStream.close();
+ return;
+ } else if (count != buffer.length) {
int rem = fileInputStream.read(buffer,count,buffer.length-count);
if (rem > 0) {
count += rem;
}
}
+ this.remainingSize -= count;
this.digest.update(buffer,0,count);
String base64 = Base64.encodeToString(buffer,0,count, Base64.NO_WRAP);
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);