Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit a06b677

Browse files
committed
feedback
1 parent 75cc0cb commit a06b677

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

CodePushDownloadHandler.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@implementation CodePushDownloadHandler {
44
// Header chars used to determine if the file is a zip.
5-
char header[4];
5+
char _header[4];
66
}
77

88
- (id)init:(NSString *)downloadFilePath
@@ -46,14 +46,14 @@ -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespons
4646

4747
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
4848
if (self.receivedContentLength < 4) {
49-
const char *bytes = [data bytes];
50-
for (int i=0; i<[data length]; i++) {
49+
for (int i = 0; i < [data length]; i++) {
5150
int headerOffset = (int)self.receivedContentLength + i;
5251
if (headerOffset >= 4) {
5352
break;
5453
}
5554

56-
header[headerOffset] = bytes[i];
55+
const char *bytes = [data bytes];
56+
_header[headerOffset] = bytes[i];
5757
}
5858
}
5959

@@ -94,7 +94,7 @@ -(void)connectionDidFinishLoading:(NSURLConnection *)connection {
9494
assert(self.receivedContentLength == self.expectedContentLength);
9595

9696
[self.outputFileStream close];
97-
BOOL isZip = header[0] == 'P' && header[1] == 'K' && header[2] == 3 && header[3] == 4;
97+
BOOL isZip = _header[0] == 'P' && _header[1] == 'K' && _header[2] == 3 && _header[3] == 4;
9898
self.doneCallback(isZip);
9999
}
100100

CodePushPackage.m

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
207207
return failCallback(error);
208208
}
209209

210-
NSString * downloadFilePath = [self getDownloadFilePath];
211-
NSString * bundleFilePath = [newPackageFolderPath stringByAppendingPathComponent:UpdateBundleFileName];
210+
NSString *downloadFilePath = [self getDownloadFilePath];
211+
NSString *bundleFilePath = [newPackageFolderPath stringByAppendingPathComponent:UpdateBundleFileName];
212212

213213
CodePushDownloadHandler *downloadHandler = [[CodePushDownloadHandler alloc]
214214
init:downloadFilePath
@@ -229,12 +229,11 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
229229
nonFailingError = nil;
230230
}
231231

232-
NSString * diffManifestFilePath = [unzippedFolderPath
233-
stringByAppendingPathComponent:DiffManifestFileName];
232+
NSString *diffManifestFilePath = [unzippedFolderPath stringByAppendingPathComponent:DiffManifestFileName];
234233

235234
if ([[NSFileManager defaultManager] fileExistsAtPath:diffManifestFilePath]) {
236235
// Copy the current package to the new package.
237-
NSString* currentPackageFolderPath = [self getCurrentPackageFolderPath:&error];
236+
NSString *currentPackageFolderPath = [self getCurrentPackageFolderPath:&error];
238237
if (error) {
239238
failCallback(error);
240239
return;
@@ -258,15 +257,13 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
258257
}
259258

260259
NSData *data = [manifestContent dataUsingEncoding:NSUTF8StringEncoding];
261-
NSDictionary* manifestJSON = [NSJSONSerialization JSONObjectWithData:data
260+
NSDictionary *manifestJSON = [NSJSONSerialization JSONObjectWithData:data
262261
options:kNilOptions
263262
error:&error];
264263
NSArray *deletedFiles = manifestJSON[@"deletedFiles"];
265264
for (NSString *deletedFileName in deletedFiles) {
266-
[[NSFileManager defaultManager]
267-
removeItemAtPath:[newPackageFolderPath
268-
stringByAppendingPathComponent:deletedFileName]
269-
error:&nonFailingError];
265+
[[NSFileManager defaultManager] removeItemAtPath:[newPackageFolderPath stringByAppendingPathComponent:deletedFileName]
266+
error:&nonFailingError];
270267

271268
if (nonFailingError) {
272269
NSLog(@"Error deleting file from current package: %@", nonFailingError);
@@ -286,7 +283,7 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
286283
}
287284

288285
NSString *relativeBundlePath = [self findMainBundleInFolder:newPackageFolderPath
289-
error:&error];
286+
error:&error];
290287
if (error) {
291288
failCallback(error);
292289
return;
@@ -314,13 +311,11 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
314311
}
315312
}
316313

317-
NSData *updateSerializedData = [NSJSONSerialization
318-
dataWithJSONObject:mutableUpdatePackage
319-
options:0
320-
error:&error];
321-
NSString *packageJsonString = [[NSString alloc]
322-
initWithData:updateSerializedData
323-
encoding:NSUTF8StringEncoding];
314+
NSData *updateSerializedData = [NSJSONSerialization dataWithJSONObject:mutableUpdatePackage
315+
options:0
316+
error:&error];
317+
NSString *packageJsonString = [[NSString alloc] initWithData:updateSerializedData
318+
encoding:NSUTF8StringEncoding];
324319

325320
[packageJsonString writeToFile:[newPackageFolderPath stringByAppendingPathComponent:@"app.json"]
326321
atomically:YES

0 commit comments

Comments
 (0)