@@ -53,6 +53,7 @@ public class CodePush {
53
53
private final String CODE_PUSH_TAG = "CodePush" ;
54
54
private final String DOWNLOAD_PROGRESS_EVENT_NAME = "CodePushDownloadProgress" ;
55
55
private final String RESOURCES_BUNDLE = "resources.arsc" ;
56
+ private final String REACT_DEV_BUNDLE_CACHE_FILE_NAME = "ReactNativeDevBundle.js" ;
56
57
57
58
private CodePushPackage codePushPackage ;
58
59
private CodePushReactPackage codePushReactPackage ;
@@ -236,6 +237,8 @@ private void initializeUpdateAfterRestart() {
236
237
// Therefore, deduce that it is a broken update and rollback.
237
238
rollbackPackage ();
238
239
} else {
240
+ // Clear the React dev bundle cache so that new updates can be loaded.
241
+ clearReactDevBundleCache ();
239
242
// Mark that we tried to initialize the new update, so that if it crashes,
240
243
// we will know that we need to rollback when the app next starts.
241
244
savePendingUpdate (pendingUpdate .getString (PENDING_UPDATE_HASH_KEY ),
@@ -248,20 +251,18 @@ private void initializeUpdateAfterRestart() {
248
251
}
249
252
}
250
253
254
+ private void clearReactDevBundleCache () {
255
+ File cachedDevBundle = new File (this .applicationContext .getFilesDir (), REACT_DEV_BUNDLE_CACHE_FILE_NAME );
256
+ if (cachedDevBundle .exists ()) {
257
+ cachedDevBundle .delete ();
258
+ }
259
+ }
260
+
251
261
private class CodePushNativeModule extends ReactContextBaseJavaModule {
252
262
253
263
private LifecycleEventListener lifecycleEventListener = null ;
254
- private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js" ;
255
-
256
- private void clearReactDevBundleCache () {
257
- File cachedDevBundle = new File (getReactApplicationContext ().getFilesDir (), JS_BUNDLE_FILE_NAME );
258
- if (cachedDevBundle .exists ()) {
259
- cachedDevBundle .delete ();
260
- }
261
- }
262
264
263
265
private void loadBundle () {
264
- clearReactDevBundleCache ();
265
266
Intent intent = mainActivity .getIntent ();
266
267
mainActivity .finish ();
267
268
mainActivity .startActivity (intent );
0 commit comments