Ben Copsey

Fix some issues with progress create by last changeset

@@ -398,16 +398,14 @@ static NSError *ASIUnableToCreateRequestError; @@ -398,16 +398,14 @@ static NSError *ASIUnableToCreateRequestError;
398 lastBytesRead = 0; 398 lastBytesRead = 0;
399 399
400 // If we're retrying a request after an authentication failure, let's remove any progress we made 400 // If we're retrying a request after an authentication failure, let's remove any progress we made
401 - if (lastBytesSent > 0 && uploadProgressDelegate) { 401 + if (lastBytesSent > 0) {
402 [self removeUploadProgressSoFar]; 402 [self removeUploadProgressSoFar];
403 } 403 }
404 404
405 lastBytesSent = 0; 405 lastBytesSent = 0;
406 if (shouldResetProgressIndicators) { 406 if (shouldResetProgressIndicators) {
407 contentLength = 0; 407 contentLength = 0;
408 - if (downloadProgressDelegate) { 408 + [self resetDownloadProgress:0];
409 - [self resetDownloadProgress:0];  
410 - }  
411 } 409 }
412 [self setResponseHeaders:nil]; 410 [self setResponseHeaders:nil];
413 if (![self downloadDestinationPath]) { 411 if (![self downloadDestinationPath]) {
@@ -633,17 +631,6 @@ static NSError *ASIUnableToCreateRequestError; @@ -633,17 +631,6 @@ static NSError *ASIUnableToCreateRequestError;
633 { 631 {
634 [progressLock lock]; 632 [progressLock lock];
635 633
636 - //We're using a progress queue or compatible controller to handle progress  
637 - SEL selector = @selector(incrementUploadSizeBy:);  
638 - if ([queue respondsToSelector:selector]) {  
639 - NSMethodSignature *signature = [[queue class] instanceMethodSignatureForSelector:selector];  
640 - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];  
641 - [invocation setTarget:queue];  
642 - [invocation setSelector:selector];  
643 - [invocation setArgument:&value atIndex:2];  
644 - [invocation invoke];  
645 - }  
646 -  
647 // Request this request's own upload progress delegate 634 // Request this request's own upload progress delegate
648 if (uploadProgressDelegate) { 635 if (uploadProgressDelegate) {
649 [ASIHTTPRequest setProgress:0 forProgressIndicator:uploadProgressDelegate]; 636 [ASIHTTPRequest setProgress:0 forProgressIndicator:uploadProgressDelegate];
@@ -137,6 +137,7 @@ @@ -137,6 +137,7 @@
137 137
138 //Tell the request not to reset the progress indicator when it gets a content-length, as we will get the length from the HEAD request 138 //Tell the request not to reset the progress indicator when it gets a content-length, as we will get the length from the HEAD request
139 [request setShouldResetProgressIndicators:NO]; 139 [request setShouldResetProgressIndicators:NO];
  140 +
140 [request addDependency:HEADRequest]; 141 [request addDependency:HEADRequest];
141 142
142 // If we want to track uploading for this request accurately, we need to add the size of the post content to the total 143 // If we want to track uploading for this request accurately, we need to add the size of the post content to the total
@@ -146,6 +147,7 @@ @@ -146,6 +147,7 @@
146 } 147 }
147 } 148 }
148 [request setShowAccurateProgress:showAccurateProgress]; 149 [request setShowAccurateProgress:showAccurateProgress];
  150 +
149 151
150 [request setQueue:self]; 152 [request setQueue:self];
151 [super addOperation:request]; 153 [super addOperation:request];