1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

Merge remote-tracking branch 'origin/master'

This commit is contained in:
tdzl2003 2016-04-05 20:07:45 +08:00
commit 50b3f3825e
2 changed files with 12 additions and 20 deletions

View File

@ -106,12 +106,13 @@ RCT_EXPORT_MODULE(RCTHotUpdate);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *packageInfo = [[defaults dictionaryForKey:rnHotUpdatePackageInfoKey] mutableCopy];
NSDictionary *ret = @{ @"downloadRootDir": [RCTHotUpdate downloadDir],
@"packageVersion": [infoDictionary objectForKey:@"CFBundleShortVersionString"],
@"currentVersion": [packageInfo objectForKey:paramCurrentVersion],
@"isFirstTime": [packageInfo objectForKey:paramIsFirstTime],
@"isRolledBack": [packageInfo objectForKey:paramIsRolledBack]
};
NSMutableDictionary *ret = [@{} mutableCopy];
ret[@"downloadRootDir"] = [RCTHotUpdate downloadDir];
ret[@"packageVersion"] = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
ret[@"currentVersion"] = [packageInfo objectForKey:paramCurrentVersion];
ret[@"isFirstTime"] = [packageInfo objectForKey:paramIsFirstTime];
ret[@"isRolledBack"] = [packageInfo objectForKey:paramIsRolledBack];
if (packageInfo) {
// clear isFirstTime and isRolledBack
packageInfo[paramIsFirstTime] = @(NO);
@ -131,20 +132,6 @@ RCT_EXPORT_MODULE(RCTHotUpdate);
return self;
}
RCT_EXPORT_METHOD(getVersionInfo:(RCTResponseSenderBlock)callback)
{
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *buildVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
NSDictionary *versionInfo = @{AppVersionKey:appVersion, BuildVersionKey:buildVersion};
if (callback) {
callback(@[versionInfo]);
}
}
RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary *)options
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)

View File

@ -58,6 +58,11 @@
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler
{
dispatch_async(_opQueue, ^{
if ([[NSFileManager defaultManager] fileExistsAtPath:destination]) {
[[NSFileManager defaultManager] removeItemAtPath:destination error:nil];
}
[SSZipArchive unzipFileAtPath:path toDestination:destination progressHandler:^(NSString *entry, unz_file_info zipInfo, long entryNumber, long total) {
progressHandler(entry, entryNumber, total);
} completionHandler:^(NSString *path, BOOL succeeded, NSError *error) {