mirror of
https://github.com/revanced/jadb.git
synced 2024-11-19 10:39:23 +01:00
Fixing a problem where errors during pull where not handled correctly.
This commit is contained in:
parent
c28902385f
commit
c051da8e7f
@ -70,10 +70,14 @@ class SyncTransport {
|
||||
output.write(buffer, offset, length);
|
||||
}
|
||||
|
||||
private int readChunk(byte[] buffer) throws IOException {
|
||||
private int readChunk(byte[] buffer) throws IOException, JadbException {
|
||||
String id = readString(4);
|
||||
if (!"DATA".equals(id)) return -1;
|
||||
int n = readInt();
|
||||
if ("FAIL".equals(id))
|
||||
{
|
||||
throw new JadbException(readString(n));
|
||||
}
|
||||
if (!"DATA".equals(id)) return -1;
|
||||
return input.read(buffer, 0, n);
|
||||
}
|
||||
|
||||
@ -86,7 +90,7 @@ class SyncTransport {
|
||||
}
|
||||
}
|
||||
|
||||
public void readChunksTo(OutputStream stream) throws IOException {
|
||||
public void readChunksTo(OutputStream stream) throws IOException, JadbException {
|
||||
byte[] buffer = new byte[1024 * 64];
|
||||
int n = readChunk(buffer);
|
||||
while (n != -1) {
|
||||
|
@ -62,4 +62,12 @@ public class RealDeviceTestCases {
|
||||
JadbDevice any = jadb.getAnyDevice();
|
||||
any.pull(new RemoteFile("/sdcard/README.md"), new File("foobar.md"));
|
||||
}
|
||||
|
||||
@Test(expected = JadbException.class)
|
||||
public void testPullInvalidFile() throws Exception
|
||||
{
|
||||
JadbConnection jadb = new JadbConnection();
|
||||
JadbDevice any = jadb.getAnyDevice();
|
||||
any.pull(new RemoteFile("/file/does/not/exist"), new File("xyz"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user