mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-28 21:15:58 -05:00
in background task, divide total required by number of combinations, and create in multiple iterations
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
parent
8316084ee7
commit
cb0c244779
@ -18,11 +18,15 @@ class BackgroundTask(config: Config, captchaManager: CaptchaManager) {
|
|||||||
val challengeGCPstmt = Statements.tlStmts.get.challengeGCPstmt
|
val challengeGCPstmt = Statements.tlStmts.get.challengeGCPstmt
|
||||||
challengeGCPstmt.executeUpdate()
|
challengeGCPstmt.executeUpdate()
|
||||||
|
|
||||||
for (param <- allParameterCombinations()) {
|
val allCombinations = allParameterCombinations()
|
||||||
val imageNum = captchaManager.getCount(param).getOrElse(0)
|
val requiredCountPerCombination = Math.max(1, (config.throttle * 1.01) / allCombinations.size).toInt
|
||||||
val countCreate = (config.throttle * 1.1).toInt - imageNum
|
|
||||||
if (countCreate > 0) {
|
for (param <- allCombinations) {
|
||||||
println(s"Creating $countCreate captchas for $param")
|
val countExisting = captchaManager.getCount(param).getOrElse(0)
|
||||||
|
val countRequired = requiredCountPerCombination - countExisting
|
||||||
|
if (countRequired > 0) {
|
||||||
|
val countCreate = Math.min(1.0 + requiredCountPerCombination/10.0, countRequired).toInt
|
||||||
|
println(s"Creating $countCreate of $countRequired captchas for $param")
|
||||||
|
|
||||||
for (i <- 0 until countCreate) {
|
for (i <- 0 until countCreate) {
|
||||||
captchaManager.generateChallenge(param)
|
captchaManager.generateChallenge(param)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user