Do not retry autodownload after SSL errors (#4821)
This commit is contained in:
parent
2588b0eca7
commit
7659fd25d8
|
@ -25,7 +25,6 @@ import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -325,18 +324,11 @@ public class DownloadService extends Service {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean httpNotFound = status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR
|
boolean unknownHost = status.getReason() == DownloadError.ERROR_UNKNOWN_HOST;
|
||||||
&& String.valueOf(HttpURLConnection.HTTP_NOT_FOUND).equals(status.getReasonDetailed());
|
boolean unsupportedType = status.getReason() == DownloadError.ERROR_UNSUPPORTED_TYPE;
|
||||||
boolean forbidden = status.getReason() == DownloadError.ERROR_FORBIDDEN
|
boolean wrongSize = status.getReason() == DownloadError.ERROR_IO_WRONG_SIZE;
|
||||||
&& String.valueOf(HttpURLConnection.HTTP_FORBIDDEN).equals(status.getReasonDetailed());
|
|
||||||
boolean notEnoughSpace = status.getReason() == DownloadError.ERROR_NOT_ENOUGH_SPACE;
|
|
||||||
boolean wrongFileType = status.getReason() == DownloadError.ERROR_FILE_TYPE;
|
|
||||||
boolean httpGone = status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR
|
|
||||||
&& String.valueOf(HttpURLConnection.HTTP_GONE).equals(status.getReasonDetailed());
|
|
||||||
boolean httpBadReq = status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR
|
|
||||||
&& String.valueOf(HttpURLConnection.HTTP_BAD_REQUEST).equals(status.getReasonDetailed());
|
|
||||||
|
|
||||||
if (httpNotFound || forbidden || notEnoughSpace || wrongFileType || httpGone || httpBadReq ) {
|
if (! (unknownHost || unsupportedType || wrongSize)) {
|
||||||
try {
|
try {
|
||||||
DBWriter.saveFeedItemAutoDownloadFailed(item).get();
|
DBWriter.saveFeedItemAutoDownloadFailed(item).get();
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
|
|
@ -223,7 +223,7 @@ public class HttpDownloader extends Downloader {
|
||||||
// written file. This check cannot be made if compression was used
|
// written file. This check cannot be made if compression was used
|
||||||
if (!isGzip && request.getSize() != DownloadStatus.SIZE_UNKNOWN &&
|
if (!isGzip && request.getSize() != DownloadStatus.SIZE_UNKNOWN &&
|
||||||
request.getSoFar() != request.getSize()) {
|
request.getSoFar() != request.getSize()) {
|
||||||
onFail(DownloadError.ERROR_IO_ERROR, "Download completed but size: " +
|
onFail(DownloadError.ERROR_IO_WRONG_SIZE, "Download completed but size: " +
|
||||||
request.getSoFar() + " does not equal expected size " + request.getSize());
|
request.getSoFar() + " does not equal expected size " + request.getSize());
|
||||||
return;
|
return;
|
||||||
} else if (request.getSize() > 0 && request.getSoFar() == 0) {
|
} else if (request.getSize() > 0 && request.getSoFar() == 0) {
|
||||||
|
|
|
@ -19,11 +19,11 @@ public enum DownloadError {
|
||||||
ERROR_NOT_ENOUGH_SPACE(10, R.string.download_error_insufficient_space),
|
ERROR_NOT_ENOUGH_SPACE(10, R.string.download_error_insufficient_space),
|
||||||
ERROR_UNKNOWN_HOST(11, R.string.download_error_unknown_host),
|
ERROR_UNKNOWN_HOST(11, R.string.download_error_unknown_host),
|
||||||
ERROR_REQUEST_ERROR(12, R.string.download_error_request_error),
|
ERROR_REQUEST_ERROR(12, R.string.download_error_request_error),
|
||||||
ERROR_DB_ACCESS_ERROR(13, R.string.download_error_db_access),
|
ERROR_DB_ACCESS_ERROR(13, R.string.download_error_db_access),
|
||||||
ERROR_UNAUTHORIZED(14, R.string.download_error_unauthorized),
|
ERROR_UNAUTHORIZED(14, R.string.download_error_unauthorized),
|
||||||
ERROR_FILE_TYPE(15, R.string.download_error_file_type_type),
|
ERROR_FILE_TYPE(15, R.string.download_error_file_type_type),
|
||||||
ERROR_FORBIDDEN(16, R.string.download_error_forbidden);
|
ERROR_FORBIDDEN(16, R.string.download_error_forbidden),
|
||||||
|
ERROR_IO_WRONG_SIZE(17, R.string.download_error_forbidden);
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
private final int resId;
|
private final int resId;
|
||||||
|
|
|
@ -243,6 +243,7 @@
|
||||||
<string name="download_error_file_type_type">File Type Error</string>
|
<string name="download_error_file_type_type">File Type Error</string>
|
||||||
<string name="download_error_forbidden">Forbidden</string>
|
<string name="download_error_forbidden">Forbidden</string>
|
||||||
<string name="download_canceled_msg">Download canceled</string>
|
<string name="download_canceled_msg">Download canceled</string>
|
||||||
|
<string name="download_wrong_size">The server connection was lost before completing the download</string>
|
||||||
<string name="download_canceled_autodownload_enabled_msg">Download canceled\nDisabled <i>Auto Download</i> for this item</string>
|
<string name="download_canceled_autodownload_enabled_msg">Download canceled\nDisabled <i>Auto Download</i> for this item</string>
|
||||||
<string name="download_report_title">Downloads completed with error(s)</string>
|
<string name="download_report_title">Downloads completed with error(s)</string>
|
||||||
<string name="auto_download_report_title">Auto-downloads completed</string>
|
<string name="auto_download_report_title">Auto-downloads completed</string>
|
||||||
|
|
Loading…
Reference in New Issue