Skip to content

Commit

Permalink
Merge pull request #134 from phound-inc/v2
Browse files Browse the repository at this point in the history
Fix for #133
  • Loading branch information
tonyofrancis authored Apr 19, 2018
2 parents ca78b14 + c2deada commit ac6af64
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FileDownloaderImpl(private val initialDownload: Download,
} else if (!isResponseSuccessful && !interrupted && !terminated) {
throw FetchException(RESPONSE_NOT_SUCCESSFUL,
FetchException.Code.REQUEST_NOT_SUCCESSFUL)
} else if(!interrupted && !terminated) {
} else if (!interrupted && !terminated) {
throw FetchException(UNKNOWN_ERROR,
FetchException.Code.UNKNOWN)
}
Expand All @@ -102,12 +102,20 @@ class FileDownloaderImpl(private val initialDownload: Download,
var error = getErrorFromThrowable(e)
error.throwable = e
if (retryOnNetworkGain) {
try {
Thread.sleep(5000)
} catch (e: InterruptedException) {
logger.e("FileDownloader", e)
var disconnectDetected = !networkInfoProvider.isNetworkAvailable
for(i in 1..10) {
try {
Thread.sleep(500)
} catch (e: InterruptedException) {
logger.e("FileDownloader", e)
break;
}
if (!networkInfoProvider.isNetworkAvailable) {
disconnectDetected = true
break;
}
}
if (!networkInfoProvider.isNetworkAvailable) {
if (disconnectDetected) {
error = Error.NO_NETWORK_CONNECTION
}
}
Expand Down

0 comments on commit ac6af64

Please sign in to comment.