mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-22 12:21:15 +00:00
Fix crash on start after improper shutdown (fixes #16).
Conflicts: src/main/java/com/nutomic/syncthingandroid/syncthing/PostTask.java src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java
This commit is contained in:
parent
665a081500
commit
de898048b7
3 changed files with 5 additions and 3 deletions
|
@ -37,7 +37,6 @@ public class GetTask extends AsyncTask<String, Void, String> {
|
|||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpGet get = new HttpGet(fullUri);
|
||||
get.addHeader(new BasicHeader("X-API-Key", params[2]));
|
||||
String responseString = null;
|
||||
try {
|
||||
HttpResponse response = httpclient.execute(get);
|
||||
HttpEntity entity = response.getEntity();
|
||||
|
|
|
@ -32,9 +32,8 @@ public class PostTask extends AsyncTask<String, Void, Void> {
|
|||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpPost post = new HttpPost(fullUri);
|
||||
post.addHeader(new BasicHeader("X-API-Key", params[2]));
|
||||
String responseString = null;
|
||||
try {
|
||||
HttpResponse response = httpclient.execute(post);
|
||||
httpclient.execute(post);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.w(TAG, "Failed to call Rest API at " + fullUri, e);
|
||||
|
|
|
@ -326,6 +326,10 @@ public class SyncthingService extends Service {
|
|||
finally {
|
||||
mApi = new RestApi("http://" + syncthingUrl, apiKey);
|
||||
Log.i(TAG, "Web GUI will be available at " + mApi.getUrl());
|
||||
// HACK: Make sure there is no syncthing binary left running from an improper
|
||||
// shutdown (eg Play Store update).
|
||||
// NOTE: This will log an exception if syncthing is not actually running.
|
||||
new PostTask().execute(mApi.getUrl(), PostTask.URI_SHUTDOWN);
|
||||
registerOnWebGuiAvailableListener(mApi);
|
||||
}
|
||||
new PollWebGuiAvailableTask().execute();
|
||||
|
|
Loading…
Reference in a new issue