mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 07:10:36 +08:00
Merge pull request #255 from Jackong/master
Fix bundle file name to support multi-bundles
This commit is contained in:
@@ -135,7 +135,7 @@ public class CodePush {
|
||||
long binaryResourcesModifiedTime = getBinaryResourcesModifiedTime();
|
||||
|
||||
try {
|
||||
String packageFilePath = codePushPackage.getCurrentPackageBundlePath();
|
||||
String packageFilePath = codePushPackage.getCurrentPackageBundlePath(this.assetsBundleFileName);
|
||||
if (packageFilePath == null) {
|
||||
// There has not been any downloaded updates.
|
||||
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
|
||||
@@ -579,7 +579,7 @@ public class CodePush {
|
||||
public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) {
|
||||
if (isUsingTestConfiguration()) {
|
||||
try {
|
||||
codePushPackage.downloadAndReplaceCurrentBundle(remoteBundleUrl);
|
||||
codePushPackage.downloadAndReplaceCurrentBundle(remoteBundleUrl, assetsBundleFileName);
|
||||
} catch (IOException e) {
|
||||
throw new CodePushUnknownException("Unable to replace current bundle", e);
|
||||
}
|
||||
@@ -628,4 +628,4 @@ public class CodePush {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ public class CodePushPackage {
|
||||
private final String RELATIVE_BUNDLE_PATH_KEY = "bundlePath";
|
||||
private final String STATUS_FILE = "codepush.json";
|
||||
private final String UNZIPPED_FOLDER_NAME = "unzipped";
|
||||
private final String UPDATE_BUNDLE_FILE_NAME = "app.jsbundle";
|
||||
|
||||
private String documentsDirectory;
|
||||
|
||||
@@ -95,7 +94,7 @@ public class CodePushPackage {
|
||||
return getPackageFolderPath(packageHash);
|
||||
}
|
||||
|
||||
public String getCurrentPackageBundlePath() {
|
||||
public String getCurrentPackageBundlePath(String bundleFileName) {
|
||||
String packageFolder = getCurrentPackageFolderPath();
|
||||
if (packageFolder == null) {
|
||||
return null;
|
||||
@@ -104,7 +103,7 @@ public class CodePushPackage {
|
||||
WritableMap currentPackage = getCurrentPackage();
|
||||
String relativeBundlePath = CodePushUtils.tryGetString(currentPackage, RELATIVE_BUNDLE_PATH_KEY);
|
||||
if (relativeBundlePath == null) {
|
||||
return CodePushUtils.appendPathComponent(packageFolder, UPDATE_BUNDLE_FILE_NAME);
|
||||
return CodePushUtils.appendPathComponent(packageFolder, bundleFileName);
|
||||
} else {
|
||||
return CodePushUtils.appendPathComponent(packageFolder, relativeBundlePath);
|
||||
}
|
||||
@@ -270,7 +269,7 @@ public class CodePushPackage {
|
||||
}
|
||||
} else {
|
||||
// File is a jsbundle, move it to a folder with the packageHash as its name
|
||||
FileUtils.moveFile(downloadFile, newUpdateFolderPath, UPDATE_BUNDLE_FILE_NAME);
|
||||
FileUtils.moveFile(downloadFile, newUpdateFolderPath, expectedBundleFileName);
|
||||
}
|
||||
|
||||
// Save metadata to the folder.
|
||||
@@ -307,7 +306,7 @@ public class CodePushPackage {
|
||||
updateCurrentPackageInfo(info);
|
||||
}
|
||||
|
||||
public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) throws IOException {
|
||||
public void downloadAndReplaceCurrentBundle(String remoteBundleUrl, String bundleFileName) throws IOException {
|
||||
URL downloadUrl;
|
||||
HttpURLConnection connection = null;
|
||||
BufferedInputStream bin = null;
|
||||
@@ -317,7 +316,7 @@ public class CodePushPackage {
|
||||
downloadUrl = new URL(remoteBundleUrl);
|
||||
connection = (HttpURLConnection) (downloadUrl.openConnection());
|
||||
bin = new BufferedInputStream(connection.getInputStream());
|
||||
File downloadFile = new File(getCurrentPackageBundlePath());
|
||||
File downloadFile = new File(getCurrentPackageBundlePath(bundleFileName));
|
||||
downloadFile.delete();
|
||||
fos = new FileOutputStream(downloadFile);
|
||||
bout = new BufferedOutputStream(fos, DOWNLOAD_BUFFER_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user