1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-22 20:31:16 +00:00

Force crash if syncthing binary returns error.

Instead of showing the loading screen forever.
This commit is contained in:
Felix Ableitner 2014-05-15 13:16:20 +02:00
parent 15f2d5e43f
commit c6456b8b1f

View file

@ -50,6 +50,7 @@ public class SyncthingService extends Service {
public void run() {
DataOutputStream dos = null;
InputStreamReader isr = null;
int ret = 1;
try {
Process p = Runtime.getRuntime().exec("sh");
dos = new DataOutputStream(p.getOutputStream());
@ -61,8 +62,7 @@ public class SyncthingService extends Service {
dos.writeBytes("exit\n");
dos.flush();
int ret = p.waitFor();
Log.d(TAG, "Syncthing binary exited with code " + Integer.toString(ret));
ret = p.waitFor();
// Write syncthing binary output to log.
// NOTE: This is only done on shutdown, not live.
@ -85,6 +85,11 @@ public class SyncthingService extends Service {
Log.e(TAG, "Failed to execute syncthing binary or read output", e);
}
finally {
if (ret != 0) {
stopSelf();
throw new RuntimeException("Syncthing binary returned error code " +
Integer.toString(ret));
}
try {
dos.close();
isr.close();