mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-09 19:53:33 +00:00
Fix crash on start after improper shutdown (fixes #16).
This commit is contained in:
parent
d524461634
commit
19123506cc
2 changed files with 5 additions and 3 deletions
|
@ -28,7 +28,7 @@ public class PostTask extends AsyncTask<String, Void, Void> {
|
||||||
* params[0] Syncthing hostname
|
* params[0] Syncthing hostname
|
||||||
* params[1] URI to call
|
* params[1] URI to call
|
||||||
* params[2] Syncthing API key
|
* params[2] Syncthing API key
|
||||||
* params[3] The request content
|
* params[3] The request content (optional)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(String... params) {
|
protected Void doInBackground(String... params) {
|
||||||
|
@ -39,7 +39,9 @@ public class PostTask extends AsyncTask<String, Void, Void> {
|
||||||
post.addHeader(new BasicHeader("X-API-Key", params[2]));
|
post.addHeader(new BasicHeader("X-API-Key", params[2]));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (params.length > 2) {
|
||||||
post.setEntity(new StringEntity(params[3]));
|
post.setEntity(new StringEntity(params[3]));
|
||||||
|
}
|
||||||
httpclient.execute(post);
|
httpclient.execute(post);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener {
|
||||||
* Restarts the syncthing binary.
|
* Restarts the syncthing binary.
|
||||||
*/
|
*/
|
||||||
public void restart() {
|
public void restart() {
|
||||||
new PostTask().execute(mUrl, PostTask.URI_RESTART, "");
|
new PostTask().execute(mUrl, PostTask.URI_RESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue