prevent crashes during rollbacks

This commit is contained in:
Geoffrey Goh
2016-08-27 18:11:43 -07:00
parent a2aacffd2c
commit 18fc035807
2 changed files with 8 additions and 5 deletions

View File

@@ -455,9 +455,12 @@ static NSString *bundleResourceSubdirectory = nil;
{
NSError *error;
NSDictionary *failedPackage = [CodePushPackage getCurrentPackage:&error];
// Write the current package's metadata to the "failed list"
[self saveFailedUpdate:failedPackage];
if (error) {
CPLog(@"Error getting current update metadata during rollback: %@", error);
} else if (failedPackage) {
// Write the current package's metadata to the "failed list"
[self saveFailedUpdate:failedPackage];
}
// Rollback to the previous version and de-register the new update
[CodePushPackage rollbackPackage];

View File

@@ -491,11 +491,13 @@ static NSString *const UnzippedFolderName = @"unzipped";
NSError *error;
NSMutableDictionary *info = [self getCurrentPackageInfo:&error];
if (error) {
CPLog(@"Error getting current package info: %@", error);
return;
}
NSString *currentPackageFolderPath = [self getCurrentPackageFolderPath:&error];
if (error) {
CPLog(@"Error getting current package folder path: %@", error);
return;
}
@@ -515,11 +517,9 @@ static NSString *const UnzippedFolderName = @"unzipped";
+ (void)updateCurrentPackageInfo:(NSDictionary *)packageInfo
error:(NSError **)error
{
NSData *packageInfoData = [NSJSONSerialization dataWithJSONObject:packageInfo
options:0
error:error];
NSString *packageInfoString = [[NSString alloc] initWithData:packageInfoData
encoding:NSUTF8StringEncoding];
[packageInfoString writeToFile:[self getStatusFilePath]