mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 04:53:13 -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
|
||||
challengeGCPstmt.executeUpdate()
|
||||
|
||||
for (param <- allParameterCombinations()) {
|
||||
val imageNum = captchaManager.getCount(param).getOrElse(0)
|
||||
val countCreate = (config.throttle * 1.1).toInt - imageNum
|
||||
if (countCreate > 0) {
|
||||
println(s"Creating $countCreate captchas for $param")
|
||||
val allCombinations = allParameterCombinations()
|
||||
val requiredCountPerCombination = Math.max(1, (config.throttle * 1.01) / allCombinations.size).toInt
|
||||
|
||||
for (param <- allCombinations) {
|
||||
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) {
|
||||
captchaManager.generateChallenge(param)
|
||||
|
Loading…
x
Reference in New Issue
Block a user