1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-27 14:47:59 +01:00

Increased file transfer buffer size.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3701 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Alex Wenckus 2006-04-04 20:44:39 +00:00 committed by alex
parent 8d3bf139c6
commit a5b061d187

View file

@ -56,7 +56,12 @@ public abstract class FileTransfer {
private Exception exception;
protected FileTransfer(String peer, String streamID,
/**
* Buffer size between input and output
*/
private static final int BUFFER_SIZE = 8192;
protected FileTransfer(String peer, String streamID,
FileTransferNegotiator negotiator) {
this.peer = peer;
this.streamID = streamID;
@ -196,20 +201,13 @@ public abstract class FileTransfer {
}
protected void writeToStream(final InputStream in, final OutputStream out)
throws XMPPException {
final byte[] b = new byte[1000];
int count;
throws XMPPException
{
final byte[] b = new byte[BUFFER_SIZE];
int count = 0;
amountWritten = 0;
try {
count = in.read(b);
} catch (IOException e) {
throw new XMPPException("error reading from input stream", e);
}
while (count != -1 && !getStatus().equals(Status.CANCLED)) {
if (getStatus().equals(Status.CANCLED)) {
return;
}
do {
// write to the output stream
try {
out.write(b, 0, count);
@ -225,10 +223,9 @@ public abstract class FileTransfer {
} catch (IOException e) {
throw new XMPPException("error reading from input stream", e);
}
}
} while (count != -1 && !getStatus().equals(Status.CANCLED));
// the connection was likely terminated abrubtly if these are not
// equal
// the connection was likely terminated abrubtly if these are not equal
if (!getStatus().equals(Status.CANCLED) && getError() == Error.NONE
&& amountWritten != fileSize) {
setStatus(Status.ERROR);