Don't retry on unrecoverable errors
This commit is contained in:
1 parent
ffaf8b9c46
commit
6f41ddda51
2 files changed
+13
-17
No files matched your search
@@ -624,14 +624,14 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
var error: String? = null
|
||||
var forceHtml = false
|
||||
var leakSkipHathKey = false
|
||||
repeat(3) {
|
||||
loop@ for (i in 1..3) {
|
||||
var imageUrl: String? = null
|
||||
var localShowKey: String?
|
||||
|
||||
showKeyLock.withLock {
|
||||
localShowKey = showKey
|
||||
if (localShowKey == null || forceHtml) {
|
||||
if (leakSkipHathKey) return@repeat
|
||||
if (leakSkipHathKey) break
|
||||
var pageUrl = EhUrl.getPageUrl(mSpiderInfo.gid, index, pToken)
|
||||
// Add skipHathKey
|
||||
if (skipHathKey != null) {
|
||||
@@ -648,7 +648,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
// Get 509
|
||||
notifyGet509(index)
|
||||
error = ERROR_509
|
||||
return@repeat
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
}.onSuccess { result ->
|
||||
@@ -670,14 +670,8 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
|
||||
showKey = result.showKey
|
||||
}.onFailure {
|
||||
if (it is ParseException && "Key mismatch" == it.message) {
|
||||
// Show key is wrong, enter a new loop to get the new show key
|
||||
if (showKey == localShowKey) showKey = null
|
||||
return@repeat
|
||||
} else {
|
||||
error = ExceptionUtils.getReadableString(it)
|
||||
return@repeat
|
||||
}
|
||||
error = ExceptionUtils.getReadableString(it)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -685,7 +679,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
if (imageUrl == null) {
|
||||
if (localShowKey == null) {
|
||||
error = "ShowKey error"
|
||||
return@repeat
|
||||
break
|
||||
}
|
||||
runSuspendCatching {
|
||||
EhEngine.getGalleryPageApi(
|
||||
@@ -699,17 +693,18 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
// Get 509
|
||||
notifyGet509(index)
|
||||
error = ERROR_509
|
||||
return@repeat
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
}.onFailure {
|
||||
if (it is ParseException && "Key mismatch" == it.message) {
|
||||
// Show key is wrong, enter a new loop to get the new show key
|
||||
if (showKey == localShowKey) showKey = null
|
||||
continue
|
||||
} else {
|
||||
error = ExceptionUtils.getReadableString(it)
|
||||
break
|
||||
}
|
||||
return@repeat
|
||||
}.onSuccess {
|
||||
imageUrl = it.imageUrl
|
||||
skipHathKey = it.skipHathKey
|
||||
@@ -729,7 +724,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
}
|
||||
if (targetImageUrl == null) {
|
||||
error = "TargetImageUrl error"
|
||||
return@repeat
|
||||
break
|
||||
}
|
||||
Log.d(WORKER_DEBUG_TAG, targetImageUrl)
|
||||
|
||||
@@ -748,13 +743,13 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
Log.e(WORKER_DEBUG_TAG, "Can't download all of image data")
|
||||
error = "Incomplete"
|
||||
forceHtml = true
|
||||
return@repeat
|
||||
continue@loop
|
||||
}
|
||||
|
||||
if (mSpiderDen.checkPlainText(index)) {
|
||||
error = ""
|
||||
forceHtml = true
|
||||
return@repeat
|
||||
continue@loop
|
||||
}
|
||||
|
||||
Log.d(WORKER_DEBUG_TAG, "Download image succeed $index")
|
||||
|
||||
Reference in new issue
Block a user