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:
parent
15f2d5e43f
commit
c6456b8b1f
1 changed files with 7 additions and 2 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue