@@ -2221,10 +2221,11 @@ public static async Task<Uri> DownloadAsync(string name) {
22212221 }
22222222
22232223 using ( Stream stream = await httpResponseMessage . Content . ReadAsStreamAsync ( ) . ConfigureAwait ( true ) ) {
2224- bool currentGoalStarted = false ;
2224+ bool useCurrentGoal = false ;
22252225
22262226 if ( httpResponseMessage . Content . Headers . ContentLength != null ) {
2227- currentGoalStarted = true ;
2227+ useCurrentGoal = true ;
2228+
22282229 ProgressManager . CurrentGoal . Start ( ( int ) Math . Ceiling ( ( double ) httpResponseMessage . Content . Headers . ContentLength . GetValueOrDefault ( ) / STREAM_READ_LENGTH ) ) ;
22292230 }
22302231
@@ -2236,23 +2237,23 @@ public static async Task<Uri> DownloadAsync(string name) {
22362237 // for large files
22372238 // temporary buffer so we don't always reallocate this
22382239 byte [ ] streamReadBuffer = new byte [ STREAM_READ_LENGTH ] ;
2239- int characterNumber = 0 ;
2240+ int streamReadLength = 0 ;
22402241
22412242 do {
22422243 // if for whatever reason there's a problem
22432244 // just ignore this download
22442245 try {
2245- characterNumber = await stream . ReadAsync ( streamReadBuffer , 0 , STREAM_READ_LENGTH ) . ConfigureAwait ( true ) ;
2246+ streamReadLength = await stream . ReadAsync ( streamReadBuffer , 0 , STREAM_READ_LENGTH ) . ConfigureAwait ( true ) ;
22462247 } catch {
22472248 break ;
22482249 }
22492250
2250- if ( currentGoalStarted ) {
2251+ if ( useCurrentGoal ) {
22512252 ProgressManager . CurrentGoal . Steps ++ ;
22522253 }
2253- } while ( characterNumber > 0 ) ;
2254+ } while ( streamReadLength > 0 ) ;
22542255 } finally {
2255- if ( currentGoalStarted ) {
2256+ if ( useCurrentGoal ) {
22562257 ProgressManager . CurrentGoal . Stop ( ) ;
22572258 }
22582259 }
0 commit comments