mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 12:51:16 +00:00
Reduce logging and number of retries for HTTP tasks.
This commit is contained in:
parent
6b6efabcc0
commit
cda06d8938
2 changed files with 8 additions and 8 deletions
|
@ -64,8 +64,8 @@ public class GetTask extends AsyncTask<String, Void, String> {
|
||||||
fullUri += "?" + URLEncodedUtils.format(urlParams, HTTP.UTF_8);
|
fullUri += "?" + URLEncodedUtils.format(urlParams, HTTP.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retry at most 10 times before failing
|
// Retry at most 5 times before failing
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
HttpClient httpclient = Https.createHttpsClient(mHttpsCertPath);
|
HttpClient httpclient = Https.createHttpsClient(mHttpsCertPath);
|
||||||
HttpGet get = new HttpGet(fullUri);
|
HttpGet get = new HttpGet(fullUri);
|
||||||
get.addHeader(new BasicHeader(RestApi.HEADER_API_KEY, params[2]));
|
get.addHeader(new BasicHeader(RestApi.HEADER_API_KEY, params[2]));
|
||||||
|
@ -91,7 +91,7 @@ public class GetTask extends AsyncTask<String, Void, String> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} catch (IOException|IllegalArgumentException e) {
|
} catch (IOException|IllegalArgumentException e) {
|
||||||
Log.w(TAG, "Failed to call Rest API at " + fullUri, e);
|
Log.w(TAG, "Failed to call Rest API at " + fullUri);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Don't push the API too hard
|
// Don't push the API too hard
|
||||||
|
@ -99,7 +99,7 @@ public class GetTask extends AsyncTask<String, Void, String> {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
Log.w(TAG, "Retrying GetTask Rest API call ("+(i+1)+"/10)");
|
Log.w(TAG, "Retrying GetTask Rest API call (" + (i + 1) + "/5)");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class PostScanTask extends AsyncTask<String, Void, Void> {
|
||||||
fullUri += "?" + URLEncodedUtils.format(urlParams, HTTP.UTF_8);
|
fullUri += "?" + URLEncodedUtils.format(urlParams, HTTP.UTF_8);
|
||||||
Log.v(TAG, "Calling Rest API at " + fullUri);
|
Log.v(TAG, "Calling Rest API at " + fullUri);
|
||||||
|
|
||||||
// Retry at most 10 times before failing
|
// Retry at most 5 times before failing
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
HttpClient httpclient = Https.createHttpsClient(mHttpsCertPath);
|
HttpClient httpclient = Https.createHttpsClient(mHttpsCertPath);
|
||||||
HttpPost post = new HttpPost(fullUri);
|
HttpPost post = new HttpPost(fullUri);
|
||||||
post.addHeader(new BasicHeader(RestApi.HEADER_API_KEY, params[1]));
|
post.addHeader(new BasicHeader(RestApi.HEADER_API_KEY, params[1]));
|
||||||
|
@ -62,7 +62,7 @@ public class PostScanTask extends AsyncTask<String, Void, Void> {
|
||||||
if (response.getEntity() != null)
|
if (response.getEntity() != null)
|
||||||
return null;
|
return null;
|
||||||
} catch (IOException | IllegalArgumentException e) {
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
Log.w(TAG, "Failed to call Rest API at " + fullUri, e);
|
Log.w(TAG, "Failed to call Rest API at " + fullUri);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Don't push the API too hard
|
// Don't push the API too hard
|
||||||
|
@ -70,7 +70,7 @@ public class PostScanTask extends AsyncTask<String, Void, Void> {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
Log.w(TAG, "Retrying GetTask Rest API call ("+(i+1)+"/10)");
|
Log.w(TAG, "Retrying GetTask Rest API call (" + (i + 1) + "/5)");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue