1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Fixed syncthing restart (fixes #137).

This commit is contained in:
Felix Ableitner 2014-10-07 12:20:26 +03:00
parent 235eb39c23
commit c588604ba8

View file

@ -48,20 +48,23 @@ public class SyncthingRunnable implements Runnable {
int ret = 1; int ret = 1;
Process process = null; Process process = null;
try { try {
process = Runtime.getRuntime().exec("sh"); // Loop to handle syncthing restarts (these always have an error code of 3).
dos = new DataOutputStream(process.getOutputStream()); do {
// Set home directory to data folder for syncthing to use. process = Runtime.getRuntime().exec("sh");
dos.writeBytes("HOME=" + mContext.getFilesDir() + " "); dos = new DataOutputStream(process.getOutputStream());
dos.writeBytes("STTRACE=" + pm.getString("sttrace", "") + " "); // Set home directory to data folder for syncthing to use.
dos.writeBytes("STNORESTART=1 "); dos.writeBytes("HOME=" + mContext.getFilesDir() + " ");
// Call syncthing with -home (as it would otherwise use "~/.config/syncthing/". dos.writeBytes("STTRACE=" + pm.getString("sttrace", "") + " ");
dos.writeBytes(mCommand + " -home " + mContext.getFilesDir() + "\n"); dos.writeBytes("STNORESTART=1 ");
dos.writeBytes("exit\n"); // Call syncthing with -home (as it would otherwise use "~/.config/syncthing/".
dos.flush(); dos.writeBytes(mCommand + " -home " + mContext.getFilesDir() + "\n");
dos.writeBytes("exit\n");
dos.flush();
log(process.getInputStream()); log(process.getInputStream());
ret = process.waitFor(); ret = process.waitFor();
} while (ret == 3);
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
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 {