Snapshot current iteration of rollback support (WIP)

This commit is contained in:
Will Anderson
2015-09-10 14:39:25 -07:00
parent 72e6e093a8
commit 71b116a6f6
3 changed files with 71 additions and 1 deletions

View File

@@ -72,6 +72,18 @@ NSString * const StatusFile = @"codepush.json";
return [self getPackageFolderPath:packageHash];
}
+ (NSString *)getCurrentPackageHash:(NSError **)error
{
NSDictionary *info = [self getCurrentPackageInfo:error];
return info[@"currentPackage"];
}
+ (NSString *)getPreviousPackageHash:(NSError **)error
{
NSDictionary *info = [self getCurrentPackageInfo:error];
return info[@"previousPackage"];
}
+ (NSDictionary *)getCurrentPackage:(NSError **)error
{
NSString *folderPath = [CodePushPackage getCurrentPackageFolderPath:error];
@@ -185,10 +197,26 @@ NSString * const StatusFile = @"codepush.json";
return;
}
[info setValue:info[@"currentPackage"] forKey:@"previousPackage"];
[info setValue:packageHash forKey:@"currentPackage"];
[self updateCurrentPackageInfo:info
error:error];
}
+ (void)rollbackPackage
{
NSError *error;
NSMutableDictionary *info = [self getCurrentPackageInfo:&error];
if (error) {
return;
}
[info setValue:info[@"previousPackage"] forKey:@"currentPackage"];
[info removeObjectForKey:@"previousPackage"];
[self updateCurrentPackageInfo:info error:&error];
}
@end