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

Commit 9b9afb6

Browse files
committed
clear dev bundle cache
1 parent 388e926 commit 9b9afb6

File tree

1 file changed

+10
-9
lines changed
  • android/app/src/main/java/com/microsoft/codepush/react

1 file changed

+10
-9
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class CodePush {
5353
private final String CODE_PUSH_TAG = "CodePush";
5454
private final String DOWNLOAD_PROGRESS_EVENT_NAME = "CodePushDownloadProgress";
5555
private final String RESOURCES_BUNDLE = "resources.arsc";
56+
private final String REACT_DEV_BUNDLE_CACHE_FILE_NAME = "ReactNativeDevBundle.js";
5657

5758
private CodePushPackage codePushPackage;
5859
private CodePushReactPackage codePushReactPackage;
@@ -236,6 +237,8 @@ private void initializeUpdateAfterRestart() {
236237
// Therefore, deduce that it is a broken update and rollback.
237238
rollbackPackage();
238239
} else {
240+
// Clear the React dev bundle cache so that new updates can be loaded.
241+
clearReactDevBundleCache();
239242
// Mark that we tried to initialize the new update, so that if it crashes,
240243
// we will know that we need to rollback when the app next starts.
241244
savePendingUpdate(pendingUpdate.getString(PENDING_UPDATE_HASH_KEY),
@@ -248,20 +251,18 @@ private void initializeUpdateAfterRestart() {
248251
}
249252
}
250253

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+
251261
private class CodePushNativeModule extends ReactContextBaseJavaModule {
252262

253263
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-
}
262264

263265
private void loadBundle() {
264-
clearReactDevBundleCache();
265266
Intent intent = mainActivity.getIntent();
266267
mainActivity.finish();
267268
mainActivity.startActivity(intent);

0 commit comments

Comments
 (0)