mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 10:21:37 +08:00
Check bundlejs before switch
This commit is contained in:
@@ -106,8 +106,8 @@ public class UpdateContext {
|
||||
private SharedPreferences sp;
|
||||
|
||||
public void switchVersion(String hashName) {
|
||||
if (!new File(rootDir, hashName).exists()) {
|
||||
throw new Error("Hash name not found, must download first.");
|
||||
if (!new File(rootDir, hashName+"/index.bundlejs").exists()) {
|
||||
throw new Error("Bundle version " + hashName + " not found.");
|
||||
}
|
||||
String lastVersion = getCurrentVersion();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
|
@@ -123,8 +123,8 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateContext.switchVersion(hash);
|
||||
try {
|
||||
updateContext.switchVersion(hash);
|
||||
Activity activity = getCurrentActivity();
|
||||
Application application = activity.getApplication();
|
||||
ReactInstanceManager instanceManager = ((ReactApplication) application).getReactNativeHost().getReactInstanceManager();
|
||||
@@ -147,7 +147,7 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
||||
}
|
||||
|
||||
} catch (Throwable err) {
|
||||
Log.e("pushy", "Failed to restart application", err);
|
||||
Log.e("pushy", "switchVersion failed", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -160,7 +160,11 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateContext.switchVersion(hash);
|
||||
try {
|
||||
updateContext.switchVersion(hash);
|
||||
} catch (Throwable err) {
|
||||
Log.e("pushy", "switchVersionLater failed", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user