CB-8699 Fix CordovaResourceApi copyResource creating zero-length files when src=uncompressed asset

This commit is contained in:
Andrew Grieve 2015-03-17 21:36:11 -04:00
parent 56d61eb44f
commit f6e56b345d

View File

@ -336,7 +336,10 @@ public class CordovaResourceApi {
if (input.assetFd != null) { if (input.assetFd != null) {
offset = input.assetFd.getStartOffset(); offset = input.assetFd.getStartOffset();
} }
outChannel.transferFrom(inChannel, offset, length); // transferFrom()'s 2nd arg is a relative position. Need to set the absolute
// position first.
inChannel.position(offset);
outChannel.transferFrom(inChannel, 0, length);
} else { } else {
final int BUFFER_SIZE = 8192; final int BUFFER_SIZE = 8192;
byte[] buffer = new byte[BUFFER_SIZE]; byte[] buffer = new byte[BUFFER_SIZE];