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