1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-29 15:51:17 +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:
Felix Ableitner 2014-06-03 17:47:14 +02:00
parent 665a081500
commit de898048b7
3 changed files with 5 additions and 3 deletions

View file

@ -37,7 +37,6 @@ public class GetTask extends AsyncTask<String, Void, String> {
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient();
HttpGet get = new HttpGet(fullUri); HttpGet get = new HttpGet(fullUri);
get.addHeader(new BasicHeader("X-API-Key", params[2])); get.addHeader(new BasicHeader("X-API-Key", params[2]));
String responseString = null;
try { try {
HttpResponse response = httpclient.execute(get); HttpResponse response = httpclient.execute(get);
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();

View file

@ -32,9 +32,8 @@ public class PostTask extends AsyncTask<String, Void, Void> {
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost(fullUri); HttpPost post = new HttpPost(fullUri);
post.addHeader(new BasicHeader("X-API-Key", params[2])); post.addHeader(new BasicHeader("X-API-Key", params[2]));
String responseString = null;
try { try {
HttpResponse response = httpclient.execute(post); httpclient.execute(post);
} }
catch (IOException e) { catch (IOException e) {
Log.w(TAG, "Failed to call Rest API at " + fullUri, e); Log.w(TAG, "Failed to call Rest API at " + fullUri, e);

View file

@ -326,6 +326,10 @@ public class SyncthingService extends Service {
finally { finally {
mApi = new RestApi("http://" + syncthingUrl, apiKey); mApi = new RestApi("http://" + syncthingUrl, apiKey);
Log.i(TAG, "Web GUI will be available at " + mApi.getUrl()); 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); registerOnWebGuiAvailableListener(mApi);
} }
new PollWebGuiAvailableTask().execute(); new PollWebGuiAvailableTask().execute();