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

Commit 165c68a

Browse files
committed
Fixing restart in debug
1 parent 44153a8 commit 165c68a

File tree

1 file changed

+13
-12
lines changed
  • android/app/src/main/java/com/microsoft/codepush/react

1 file changed

+13
-12
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,20 @@ public CodePush(String deploymentKey, Activity mainActivity, boolean isDebugMode
107107
}
108108

109109
currentInstance = this;
110+
111+
clearDebugCacheIfNeeded();
110112
}
111113

114+
private void clearDebugCacheIfNeeded() {
115+
if (isDebugMode && isPendingUpdate(null)) {
116+
// This needs to be kept in sync with https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java#L78
117+
File cachedDevBundle = new File(applicationContext.getFilesDir(), "ReactNativeDevBundle.js");
118+
if (cachedDevBundle.exists()) {
119+
cachedDevBundle.delete();
120+
}
121+
}
122+
}
123+
112124
private long getBinaryResourcesModifiedTime() {
113125
ZipFile applicationFile = null;
114126
try {
@@ -374,14 +386,6 @@ public String getName() {
374386
public void initialize() {
375387
CodePush.this.initializeUpdateAfterRestart();
376388
}
377-
378-
private void clearReactDevBundleCache() {
379-
// This needs to be kept in sync with https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java#L78
380-
File cachedDevBundle = new File(CodePush.this.applicationContext.getFilesDir(), "ReactNativeDevBundle.js");
381-
if (cachedDevBundle.exists()) {
382-
cachedDevBundle.delete();
383-
}
384-
}
385389

386390
private void loadBundleLegacy() {
387391
Intent intent = mainActivity.getIntent();
@@ -392,10 +396,7 @@ private void loadBundleLegacy() {
392396
}
393397

394398
private void loadBundle() {
395-
// Clear the React dev bundle cache so that new updates can be loaded.
396-
if (CodePush.this.isDebugMode) {
397-
clearReactDevBundleCache();
398-
}
399+
CodePush.this.clearDebugCacheIfNeeded();
399400

400401
try {
401402
// #1) Get the private ReactInstanceManager, which is what includes

0 commit comments

Comments
 (0)