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

Improve Volley retry policy to problems with events (fixes #904)

This commit is contained in:
Felix Ableitner 2017-11-05 21:50:03 +09:00
parent 433829036d
commit cb5e9b48ba
2 changed files with 6 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import android.util.Log;
import android.widget.ImageView;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HurlStack;
@ -113,6 +114,11 @@ public abstract class ApiRequest {
return Optional.fromNullable(requestBody).transform(String::getBytes).orNull();
}
};
// Some requests seem to be slow or fail, make sure this doesn't break the app
// (eg if an event request fails, new event requests won't be triggered).
request.setRetryPolicy(new DefaultRetryPolicy(5000, 5,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
getVolleyQueue().add(request);
}

View file

@ -150,7 +150,6 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
File updatedFile = new File(folderPath, (String) event.data.get("item"));
if (!"delete".equals(event.data.get("action"))) {
Log.i(TAG, "Rescanned file via MediaScanner: " + updatedFile.toString());
Log.d("xxx", "update intent sent for " + updatedFile.getName());
MediaScannerConnection.scanFile(mContext, new String[]{updatedFile.getPath()},
null, null);
} else {