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

Commit 587f9b2

Browse files
committed
Merge pull request #255 from Jackong/master
Fix bundle file name to support multi-bundles
2 parents ac38eaa + 5a17406 commit 587f9b2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public String getBundleUrl(String assetsBundleFileName) {
135135
long binaryResourcesModifiedTime = getBinaryResourcesModifiedTime();
136136

137137
try {
138-
String packageFilePath = codePushPackage.getCurrentPackageBundlePath();
138+
String packageFilePath = codePushPackage.getCurrentPackageBundlePath(this.assetsBundleFileName);
139139
if (packageFilePath == null) {
140140
// There has not been any downloaded updates.
141141
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
@@ -579,7 +579,7 @@ public void restartApp(boolean onlyIfUpdateIsPending) {
579579
public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) {
580580
if (isUsingTestConfiguration()) {
581581
try {
582-
codePushPackage.downloadAndReplaceCurrentBundle(remoteBundleUrl);
582+
codePushPackage.downloadAndReplaceCurrentBundle(remoteBundleUrl, assetsBundleFileName);
583583
} catch (IOException e) {
584584
throw new CodePushUnknownException("Unable to replace current bundle", e);
585585
}
@@ -628,4 +628,4 @@ public List<ViewManager> createViewManagers(ReactApplicationContext reactApplica
628628
return new ArrayList<>();
629629
}
630630
}
631-
}
631+
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class CodePushPackage {
3131
private final String RELATIVE_BUNDLE_PATH_KEY = "bundlePath";
3232
private final String STATUS_FILE = "codepush.json";
3333
private final String UNZIPPED_FOLDER_NAME = "unzipped";
34-
private final String UPDATE_BUNDLE_FILE_NAME = "app.jsbundle";
3534

3635
private String documentsDirectory;
3736

@@ -95,7 +94,7 @@ public String getCurrentPackageFolderPath() {
9594
return getPackageFolderPath(packageHash);
9695
}
9796

98-
public String getCurrentPackageBundlePath() {
97+
public String getCurrentPackageBundlePath(String bundleFileName) {
9998
String packageFolder = getCurrentPackageFolderPath();
10099
if (packageFolder == null) {
101100
return null;
@@ -104,7 +103,7 @@ public String getCurrentPackageBundlePath() {
104103
WritableMap currentPackage = getCurrentPackage();
105104
String relativeBundlePath = CodePushUtils.tryGetString(currentPackage, RELATIVE_BUNDLE_PATH_KEY);
106105
if (relativeBundlePath == null) {
107-
return CodePushUtils.appendPathComponent(packageFolder, UPDATE_BUNDLE_FILE_NAME);
106+
return CodePushUtils.appendPathComponent(packageFolder, bundleFileName);
108107
} else {
109108
return CodePushUtils.appendPathComponent(packageFolder, relativeBundlePath);
110109
}
@@ -270,7 +269,7 @@ public void downloadPackage(ReadableMap updatePackage, String expectedBundleFile
270269
}
271270
} else {
272271
// File is a jsbundle, move it to a folder with the packageHash as its name
273-
FileUtils.moveFile(downloadFile, newUpdateFolderPath, UPDATE_BUNDLE_FILE_NAME);
272+
FileUtils.moveFile(downloadFile, newUpdateFolderPath, expectedBundleFileName);
274273
}
275274

276275
// Save metadata to the folder.
@@ -307,7 +306,7 @@ public void rollbackPackage() {
307306
updateCurrentPackageInfo(info);
308307
}
309308

310-
public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) throws IOException {
309+
public void downloadAndReplaceCurrentBundle(String remoteBundleUrl, String bundleFileName) throws IOException {
311310
URL downloadUrl;
312311
HttpURLConnection connection = null;
313312
BufferedInputStream bin = null;
@@ -317,7 +316,7 @@ public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) throws IOExc
317316
downloadUrl = new URL(remoteBundleUrl);
318317
connection = (HttpURLConnection) (downloadUrl.openConnection());
319318
bin = new BufferedInputStream(connection.getInputStream());
320-
File downloadFile = new File(getCurrentPackageBundlePath());
319+
File downloadFile = new File(getCurrentPackageBundlePath(bundleFileName));
321320
downloadFile.delete();
322321
fos = new FileOutputStream(downloadFile);
323322
bout = new BufferedOutputStream(fos, DOWNLOAD_BUFFER_SIZE);

0 commit comments

Comments
 (0)