mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-19 19:39:54 +08:00
Snapshot current iteration of rollback support (WIP)
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user