mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 12994: fix IndexOutOfBoundsException problem in VMDK upload
This commit is contained in:
parent
bcd58e3ae3
commit
c89f6e2936
@ -335,15 +335,14 @@ public class VmwareContext {
|
||||
try {
|
||||
bos = new BufferedOutputStream(conn.getOutputStream());
|
||||
is = new BufferedInputStream(new FileInputStream(localFileName));
|
||||
int bytesAvailable = is.available();
|
||||
int bufferSize = Math.min(bytesAvailable, _CHUNKSIZE);
|
||||
int bufferSize = _CHUNKSIZE;
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
while (true) {
|
||||
int bytesRead = is.read(buffer, 0, bufferSize);
|
||||
if (bytesRead == -1) {
|
||||
break;
|
||||
}
|
||||
bos.write(buffer, 0, bufferSize);
|
||||
}
|
||||
bos.write(buffer, 0, bytesRead);
|
||||
totalBytesUpdated += bytesRead;
|
||||
bos.flush();
|
||||
if(progressUpdater != null)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user