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

Commit e27968e

Browse files
committed
Android implementation
1 parent eee43ec commit e27968e

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ protected Void doInBackground(Object... params) {
365365
try {
366366
WritableMap mutableUpdatePackage = CodePushUtils.convertReadableMapToWritableMap(updatePackage);
367367
mutableUpdatePackage.putString(BINARY_MODIFIED_TIME_KEY, "" + getBinaryResourcesModifiedTime());
368-
codePushPackage.downloadPackage(applicationContext, mutableUpdatePackage, new DownloadProgressCallback() {
368+
codePushPackage.downloadPackage(applicationContext, mutableUpdatePackage, CodePush.this.assetsBundleFileName, new DownloadProgressCallback() {
369369
@Override
370370
public void call(DownloadProgress downloadProgress) {
371371
getReactApplicationContext()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public WritableMap getPackage(String packageHash) {
151151
}
152152
}
153153

154-
public void downloadPackage(Context applicationContext, ReadableMap updatePackage,
154+
public void downloadPackage(Context applicationContext, ReadableMap updatePackage, String expectedBundleFileName,
155155
DownloadProgressCallback progressCallback) throws IOException {
156156
String newUpdateHash = CodePushUtils.tryGetString(updatePackage, PACKAGE_HASH_KEY);
157157
String newUpdateFolderPath = getPackageFolderPath(newUpdateHash);
@@ -243,7 +243,7 @@ public void downloadPackage(Context applicationContext, ReadableMap updatePackag
243243

244244
// For zip updates, we need to find the relative path to the jsBundle and save it in the
245245
// metadata so that we can find and run it easily the next time.
246-
String relativeBundlePath = CodePushUpdateUtils.findJSBundleInUpdateContents(newUpdateFolderPath);
246+
String relativeBundlePath = CodePushUpdateUtils.findJSBundleInUpdateContents(newUpdateFolderPath, expectedBundleFileName);
247247

248248
if (relativeBundlePath == null) {
249249
throw new CodePushInvalidUpdateException("Update is invalid - no files with extension .bundle, .js or .jsbundle were found in the update package.");

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,20 @@ public static void copyNecessaryFilesFromCurrentPackage(String diffManifestFileP
7979
}
8080
}
8181

82-
public static String findJSBundleInUpdateContents(String folderPath) {
82+
public static String findJSBundleInUpdateContents(String folderPath, String expectedFileName) {
8383
File folder = new File(folderPath);
8484
File[] folderFiles = folder.listFiles();
8585
for (File file : folderFiles) {
8686
String fullFilePath = CodePushUtils.appendPathComponent(folderPath, file.getName());
8787
if (file.isDirectory()) {
88-
String mainBundlePathInSubFolder = findJSBundleInUpdateContents(fullFilePath);
88+
String mainBundlePathInSubFolder = findJSBundleInUpdateContents(fullFilePath, expectedFileName);
8989
if (mainBundlePathInSubFolder != null) {
9090
return CodePushUtils.appendPathComponent(file.getName(), mainBundlePathInSubFolder);
9191
}
9292
} else {
9393
String fileName = file.getName();
94-
int dotIndex = fileName.lastIndexOf(".");
95-
if (dotIndex >= 0) {
96-
String fileExtension = fileName.substring(dotIndex + 1);
97-
if (fileExtension.equals("bundle") || fileExtension.equals("js") || fileExtension.equals("jsbundle")) {
98-
return fileName;
99-
}
94+
if (fileName.equals(expectedFileName)) {
95+
return fileName;
10096
}
10197
}
10298
}

0 commit comments

Comments
 (0)