This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7676@property (copy ) void (^progressCallback)(long long , long long );
7777@property (copy ) void (^doneCallback)(BOOL );
7878@property (copy ) void (^failCallback)(NSError *err);
79+ @property NSString *downloadUrl;
7980
8081- (id )init : (NSString *)downloadFilePath
8182operationQueue : (dispatch_queue_t )operationQueue
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ - (id)init:(NSString *)downloadFilePath
2020 return self;
2121}
2222
23- - (void )download : (NSString *)url {
23+ - (void )download : (NSString *)url {
24+ self.downloadUrl = url;
2425 NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: url]
2526 cachePolicy: NSURLRequestUseProtocolCachePolicy
2627 timeoutInterval: 60.0 ];
@@ -53,10 +54,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespon
5354 if (statusCode >= 400 ) {
5455 [self .outputFileStream close ];
5556 [connection cancel ];
56-
57- NSError *err = [NSError errorWithDomain: @" http download error"
58- code: statusCode
59- userInfo: nil ];
57+ NSError *err = [CodePushErrorUtils errorWithMessage: [NSString stringWithFormat: @" Received %ld response from %@ " , (long )statusCode, self .downloadUrl]];
6058 self.failCallback (err);
6159 return ;
6260 }
@@ -113,13 +111,8 @@ - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
113111
114112- (void )connectionDidFinishLoading : (NSURLConnection *)connection {
115113 [self .outputFileStream close ];
116-
117- // MUST have received bytes from remote server. do not do this, we will get a 0 bytes file of download.zip in download directory,
118- // the variable isZip is FALSE and download.zip will be renamed app.bundle that occurring by self.doneCallback(isZip) method.
119114 if (self.receivedContentLength < 1 ) {
120- NSError *err = [NSError errorWithDomain: @" received nothing"
121- code: -1
122- userInfo: nil ];
115+ NSError *err = [CodePushErrorUtils errorWithMessage: [NSString stringWithFormat: @" Received empty response from %@ " , self .downloadUrl]];
123116 self.failCallback (err);
124117 return ;
125118 }
You can’t perform that action at this time.
0 commit comments