This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +19
-9
lines changed
Examples/CodePushDemoApp/CodePushDemoAppTests/ApplyUpdateTests Expand file tree Collapse file tree 5 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ failCallback:(void (^)(NSError *err))failCallback;
54
54
55
55
+ (NSDictionary *)getCurrentPackage : (NSError **)error ;
56
56
+ (NSString *)getCurrentPackageFolderPath : (NSError **)error ;
57
+ + (NSString *)getCurrentPackageBundlePath : (NSError **)error ;
57
58
+ (NSString *)getCurrentPackageHash : (NSError **)error ;
58
59
59
60
+ (NSDictionary *)getPackage : (NSString *)packageHash
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ @implementation CodePush
14
14
15
15
NSString * const FailedUpdatesKey = @" CODE_PUSH_FAILED_UPDATES" ;
16
16
NSString * const PendingUpdateKey = @" CODE_PUSH_PENDING_UPDATE" ;
17
- NSString * const UpdateBundleFileName = @" app.jsbundle" ;
18
17
19
18
@synthesize bridge = _bridge;
20
19
@@ -28,16 +27,14 @@ + (NSString *)getDocumentsDirectory
28
27
+ (NSURL *)getBundleUrl
29
28
{
30
29
NSError *error;
31
- NSString *packageFolder = [CodePushPackage getCurrentPackageFolderPath : &error];
30
+ NSString *packageFile = [CodePushPackage getCurrentPackageBundlePath : &error];
32
31
NSURL *binaryJsBundleUrl = [[NSBundle mainBundle ] URLForResource: @" main" withExtension: @" jsbundle" ];
33
32
34
- if (error || !packageFolder )
33
+ if (error || !packageFile )
35
34
{
36
35
return binaryJsBundleUrl;
37
36
}
38
37
39
- NSString *packageFile = [packageFolder stringByAppendingPathComponent: UpdateBundleFileName];
40
-
41
38
NSDictionary *binaryFileAttributes = [[NSFileManager defaultManager ] attributesOfItemAtPath: [binaryJsBundleUrl path ] error: nil ];
42
39
NSDictionary *appFileAttribs = [[NSFileManager defaultManager ] attributesOfItemAtPath: packageFile error: nil ];
43
40
NSDate *binaryDate = [binaryFileAttributes objectForKey: NSFileModificationDate ];
Original file line number Diff line number Diff line change 3
3
@implementation CodePushPackage
4
4
5
5
NSString * const StatusFile = @" codepush.json" ;
6
+ NSString * const UpdateBundleFileName = @" app.jsbundle" ;
6
7
7
8
+ (NSString *)getCodePushPath
8
9
{
@@ -72,6 +73,17 @@ + (NSString *)getCurrentPackageFolderPath:(NSError **)error
72
73
return [self getPackageFolderPath: packageHash];
73
74
}
74
75
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
+
75
87
+ (NSString *)getCurrentPackageHash : (NSError **)error
76
88
{
77
89
NSDictionary *info = [self getCurrentPackageInfo: error];
@@ -167,10 +179,10 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
167
179
return failCallback (error);
168
180
}
169
181
170
- NSString *updateBundleFileName = [packageFolderPath stringByAppendingPathComponent: @" app.jsbundle " ];
182
+ NSString *downloadFilePath = [packageFolderPath stringByAppendingPathComponent: UpdateBundleFileName ];
171
183
172
184
CodePushDownloadHandler *downloadHandler = [[CodePushDownloadHandler alloc ]
173
- init: updateBundleFileName
185
+ init: downloadFilePath
174
186
progressCallback: progressCallback
175
187
doneCallback: ^{
176
188
NSError *error;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ var DownloadAndApplyUpdateTest = React.createClass({
39
39
runTest ( ) {
40
40
var update = require ( "./TestPackage" ) ;
41
41
NativeBridge . downloadUpdate ( update ) . done ( ( downloadedPackage ) => {
42
- NativeBridge . applyUpdate ( downloadedPackage , 1000 ) ;
42
+ NativeBridge . applyUpdate ( downloadedPackage , /*rollbackTimeout*/ 1000 , /*restartImmediately*/ true ) ;
43
43
} ) ;
44
44
} ,
45
45
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module.exports = (NativeCodePush) => {
15
15
if ( progressHandler ) {
16
16
// Use event subscription to obtain download progress.
17
17
downloadProgressSubscription = NativeAppEventEmitter . addListener (
18
- ' CodePushDownloadProgress' ,
18
+ " CodePushDownloadProgress" ,
19
19
progressHandler
20
20
) ;
21
21
}
You can’t perform that action at this time.
0 commit comments