This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change 76
76
@property (copy ) void (^progressCallback)(long long , long long );
77
77
@property (copy ) void (^doneCallback)(BOOL );
78
78
@property (copy ) void (^failCallback)(NSError *err);
79
+ @property NSString *downloadUrl;
79
80
80
81
- (id )init : (NSString *)downloadFilePath
81
82
operationQueue : (dispatch_queue_t )operationQueue
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ - (id)init:(NSString *)downloadFilePath
20
20
return self;
21
21
}
22
22
23
- - (void )download : (NSString *)url {
23
+ - (void )download : (NSString *)url {
24
+ self.downloadUrl = url;
24
25
NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: url]
25
26
cachePolicy: NSURLRequestUseProtocolCachePolicy
26
27
timeoutInterval: 60.0 ];
@@ -53,10 +54,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespon
53
54
if (statusCode >= 400 ) {
54
55
[self .outputFileStream close ];
55
56
[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]];
60
58
self.failCallback (err);
61
59
return ;
62
60
}
@@ -113,13 +111,8 @@ - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
113
111
114
112
- (void )connectionDidFinishLoading : (NSURLConnection *)connection {
115
113
[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.
119
114
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]];
123
116
self.failCallback (err);
124
117
return ;
125
118
}
You can’t perform that action at this time.
0 commit comments