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

Commit 5566742

Browse files
committed
fixed test and deduplicate
1 parent e0dc4f5 commit 5566742

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

CodePush.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ failCallback:(void (^)(NSError *err))failCallback;
5454

5555
+ (NSDictionary *)getCurrentPackage:(NSError **)error;
5656
+ (NSString *)getCurrentPackageFolderPath:(NSError **)error;
57+
+ (NSString *)getCurrentPackageBundlePath:(NSError **)error;
5758
+ (NSString *)getCurrentPackageHash:(NSError **)error;
5859

5960
+ (NSDictionary *)getPackage:(NSString *)packageHash

CodePush.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ @implementation CodePush
1414

1515
NSString * const FailedUpdatesKey = @"CODE_PUSH_FAILED_UPDATES";
1616
NSString * const PendingUpdateKey = @"CODE_PUSH_PENDING_UPDATE";
17-
NSString * const UpdateBundleFileName = @"app.jsbundle";
1817

1918
@synthesize bridge = _bridge;
2019

@@ -28,16 +27,14 @@ + (NSString *)getDocumentsDirectory
2827
+ (NSURL *)getBundleUrl
2928
{
3029
NSError *error;
31-
NSString *packageFolder = [CodePushPackage getCurrentPackageFolderPath:&error];
30+
NSString *packageFile = [CodePushPackage getCurrentPackageBundlePath:&error];
3231
NSURL *binaryJsBundleUrl = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
3332

34-
if (error || !packageFolder)
33+
if (error || !packageFile)
3534
{
3635
return binaryJsBundleUrl;
3736
}
3837

39-
NSString *packageFile = [packageFolder stringByAppendingPathComponent:UpdateBundleFileName];
40-
4138
NSDictionary *binaryFileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[binaryJsBundleUrl path] error:nil];
4239
NSDictionary *appFileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:packageFile error:nil];
4340
NSDate *binaryDate = [binaryFileAttributes objectForKey:NSFileModificationDate];

CodePushPackage.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@implementation CodePushPackage
44

55
NSString * const StatusFile = @"codepush.json";
6+
NSString * const UpdateBundleFileName = @"app.jsbundle";
67

78
+ (NSString *)getCodePushPath
89
{
@@ -72,6 +73,17 @@ + (NSString *)getCurrentPackageFolderPath:(NSError **)error
7273
return [self getPackageFolderPath:packageHash];
7374
}
7475

76+
+ (NSString *)getCurrentPackageBundlePath:(NSError **)error
77+
{
78+
NSString *packageFolder = [self getCurrentPackageFolderPath:error];
79+
80+
if(*error) {
81+
return NULL;
82+
}
83+
84+
return [packageFolder stringByAppendingPathComponent:UpdateBundleFileName];
85+
}
86+
7587
+ (NSString *)getCurrentPackageHash:(NSError **)error
7688
{
7789
NSDictionary *info = [self getCurrentPackageInfo:error];
@@ -167,10 +179,10 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
167179
return failCallback(error);
168180
}
169181

170-
NSString *updateBundleFileName = [packageFolderPath stringByAppendingPathComponent:@"app.jsbundle"];
182+
NSString *downloadFilePath = [packageFolderPath stringByAppendingPathComponent:UpdateBundleFileName];
171183

172184
CodePushDownloadHandler *downloadHandler = [[CodePushDownloadHandler alloc]
173-
init:updateBundleFileName
185+
init:downloadFilePath
174186
progressCallback:progressCallback
175187
doneCallback:^{
176188
NSError *error;

Examples/CodePushDemoApp/CodePushDemoAppTests/ApplyUpdateTests/DownloadAndApplyUpdateTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var DownloadAndApplyUpdateTest = React.createClass({
3939
runTest() {
4040
var update = require("./TestPackage");
4141
NativeBridge.downloadUpdate(update).done((downloadedPackage) => {
42-
NativeBridge.applyUpdate(downloadedPackage, 1000);
42+
NativeBridge.applyUpdate(downloadedPackage, /*rollbackTimeout*/ 1000, /*restartImmediately*/ true);
4343
});
4444
},
4545

package-mixins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = (NativeCodePush) => {
1515
if (progressHandler) {
1616
// Use event subscription to obtain download progress.
1717
downloadProgressSubscription = NativeAppEventEmitter.addListener(
18-
'CodePushDownloadProgress',
18+
"CodePushDownloadProgress",
1919
progressHandler
2020
);
2121
}

0 commit comments

Comments
 (0)