Progress update bar

I found the package progress very useful, but I have a case in mind where the total amount is being updated. Is there some way to update the progress bar?

So far if I found that if I continue with the loop it returns an error

Error in pb_tick(self, private, len, tokens) : !self$finished is not TRUE  

And not sure if/how to create a new a progress bar when the loop extends further than anticipated.

Some pseudo-code

len <- 100
pb <- progress::progress_bar$new(
      format = "Downloading multiple pages :bar",
      total = len
    ) 
i <- 1
repeat { 
    # Something complex
    if (condition) {
        pb$total <- 200
    }
    pb$tick() 
    i <- i +1

    if (cond2) {
        break
    }
}

Related to this: Is it possible to finish the progress bar earlier?


Sorry couldn't find a more specific tag or site to ask.

Could you create at least a rough reprex? That would save me a little time when looking into this.

Of course:

len <- 100
pb <- progress::progress_bar$new(
      format = "Downloading multiple pages :bar",
      total = len
    ) 
pb$total <- 500
pb$finish()