More precise progress indication
This fix solves divison by 0 and incorrect percentage report when extractImage is used
This commit is contained in:
		
					parent
					
						
							
								f95004f417
							
						
					
				
			
			
				commit
				
					
						98ea16f21b
					
				
			
		
					 1 changed files with 9 additions and 4 deletions
				
			
		|  | @ -152,15 +152,20 @@ abstract class ProgressHelper implements HelperInterface | ||||||
|         $currentDuration = $this->convertDuration($matches[2]); |         $currentDuration = $this->convertDuration($matches[2]); | ||||||
|         $currentTime = $this->microtimeFloat(); |         $currentTime = $this->microtimeFloat(); | ||||||
|         $currentSize = trim(str_replace('kb', '', strtolower(($matches[1])))); |         $currentSize = trim(str_replace('kb', '', strtolower(($matches[1])))); | ||||||
|         $percent = $currentDuration/ $this->duration; |         $percent = max(0, min(1, $currentDuration / $this->duration)); | ||||||
| 
 | 
 | ||||||
|         if ($this->lastOutput !== null) { |         if ($this->lastOutput !== null) { | ||||||
|             $delta = $currentTime - $this->lastOutput; |             $delta = $currentTime - $this->lastOutput; | ||||||
|             $deltaSize = $currentSize - $this->currentSize; |             $deltaSize = $currentSize - $this->currentSize; | ||||||
|             $rate = $deltaSize * $delta; |             $rate = $deltaSize * $delta; | ||||||
|             $totalDuration = $this->totalSize / $rate; |             if ($rate > 0) { | ||||||
|             $this->remaining = floor($totalDuration - ($totalDuration * $percent)); |                 $totalDuration = $this->totalSize / $rate; | ||||||
|             $this->rate = floor($rate); |                 $this->remaining = floor($totalDuration - ($totalDuration * $percent)); | ||||||
|  |                 $this->rate = floor($rate); | ||||||
|  |             } else { | ||||||
|  |                 $this->remaining = 0; | ||||||
|  |                 $this->rate = 0; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $this->percent = floor($percent * 100); |         $this->percent = floor($percent * 100); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue